我有一個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