我有一个custom cell
与textfield
作为子视图。将单元设置为textfield
的代表是否合法?自定义UITableViewCell委托其子视图?
我想将单元格设置为委托,因为它是父视图,但是当我这样做时,应用程序崩溃。我想这是因为table view dequeue cells
,也许这就是为什么代表参考在两者之间迷失的原因。 所以,我试图设置cellForRowAtIndexPath
的委托,以确保它每次都新鲜设置,但它仍然无法工作。
难道我真的不得不提高水平,让tableview controller
成为单元格子视图的代表吗?还是我缺少别的东西?
崩溃报告输出:
>libobjc.A.dylib`objc_msgSend:
>
0x32ed4f78: ldr r3, [r4, #8]
>
initWithStyle我
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier type: (NSString *)cellType
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:@"Custom Cell" owner:self options:nil];
self = [nibArray lastObject];
self.cellType = [NSString stringWithString:cellType];
self.contentText.autoresizingMask = UIViewAutoresizingNone;
self.detailLabel.autoresizingMask = UIViewAutoresizingNone;
self.contentText.delegate = self;
}
return self;
}
谢谢拉维,我发布了我的代码 –
在你的情况下,错误“objc_msgSend”似乎发生,因为该对象被释放。您可能需要发布完整的错误消息,以了解哪种方法导致错误。另外,像endy提到的,你并不需要在你的表视图委托/数据源方法中分配委托。 – Ravi