你好,亲爱的程序员的动态数量,定制的TableView细胞创建与对象
我有下面的方法创建一个自定义tableviewcell要求:
@interface CustomTableCell : UITableViewCell {
}
@implementation CustomTableCell
-(void)setObjectWithType:(NSString *)objectType atPlace:(CGRect) placeOfObject
{
class className=NSClassFromString(objectType);
className *objectName = [[NSClassFromString(objectType) alloc] init];// Giving error
}
请解决这个问题,以创建任何类型的通过传递如下参数的对象:
CustomTableCell *cell=[[CustomTableCell alloc] init];
[cell setObjectWithType:@"UILabel" atPlace:CGRectMake(0, 0, 100, 30)];
谢谢,提前。
这不是太复杂吗?为什么不在调用之前创建对象并传递创建的对象? – Sulthan