0

我有custom cell一个textfield作为子视图的。将单元格设置为代表是否合法textfield

我想将单元格设置为委托,因为它是父视图,但是当我这样做时,应用程序崩溃了。我想这是因为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;
}
4

2 回答 2

0

不要设置delegatecellForRowAtIndexPath.

在您的UITableViewCell子类中添加方法,然后UITextField在其中设置。initWithStyledelegateself

于 2012-12-19T05:47:16.170 回答
0

将自定义单元格作为单元格中文本字段的委托根本不是问题。表格视图将在需要时重用一些单元格,但这不会影响任何事情。我猜你错过了别的东西。如果您发布崩溃时遇到的错误以及相应的代码片段,也许我可以提供帮助。

于 2012-12-19T05:32:39.083 回答