1
我在另一個表內部有一個表。我可以在沒有任何問題的情況下將單元格添加到「超類」和「子表」中 - 它們將顯示,滾動等。但是,當我嘗試與「子表」交互時(選擇其中一個文本框進行編輯)崩潰。我跑的程序殭屍工具,它backtraced崩潰這個代碼(我使用ARC):TableView從ARC創建殭屍autorelease
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (saveTheTable == nil) saveTheTable = tableView;
static NSString *licenseCellId = @"licenseID";
UINib *nib = [UINib nibWithNibName:@"LicenseCell" bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:licenseCellId];
//This line causes the crash
LicenseCell *cell = [tableView dequeueReusableCellWithIdentifier:licenseCellId];
cell.delegate = self;
[licenseFields replaceObjectAtIndex:indexPath.row withObject:cell];
return cell;
}
該負責呼叫者給出UITextField。看起來,「子表」正在被autoreleasepool排水管釋放。爲什麼會這樣,我該如何解決它?我嘗試存儲對單元格的強引用。
CNC中也許回溯將有助於
* thread #1: tid = 0x1f03, 0x017a309b libobjc.A.dylib`objc_msgSend + 15, stop reason = EXC_BAD_ACCESS (code=2, address=0x8)
frame #0: 0x017a309b libobjc.A.dylib`objc_msgSend + 15
frame #1: 0x003c7c7e UIKit`-[UITextField canBecomeFirstResponder] + 167
frame #2: 0x00405fe7 UIKit`-[UIResponder becomeFirstResponder] + 179
frame #3: 0x005e58fb UIKit`-[UITextInteractionAssistant setFirstResponderIfNecessary] + 208
frame #4: 0x005e75f8 UIKit`-[UITextInteractionAssistant oneFingerTap:] + 1989
frame #5: 0x005dfe29 UIKit`_UIGestureRecognizerSendActions + 143
frame #6: 0x005df133 UIKit`-[UIGestureRecognizer _updateGestureWithEvent:] + 379
frame #7: 0x005e03bf UIKit`-[UIGestureRecognizer _delayedUpdateGesture] + 46
frame #8: 0x005e2a21 UIKit`___UIGestureRecognizerUpdate_block_invoke_0541 + 57
frame #9: 0x005e297c UIKit`_UIGestureRecognizerApplyBlocksToArray + 277
frame #10: 0x005db3d7 UIKit`_UIGestureRecognizerUpdate + 1026
frame #11: 0x003401a2 UIKit`-[UIWindow _sendGesturesForEvent:] + 1121
frame #12: 0x00340532 UIKit`-[UIWindow sendEvent:] + 93
frame #13: 0x00326dc4 UIKit`-[UIApplication sendEvent:] + 464
frame #14: 0x0031a634 UIKit`_UIApplicationHandleEvent + 8196
frame #15: 0x01f9aef5 GraphicsServices`PurpleEventCallback + 1274
frame #16: 0x012b3195 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
frame #17: 0x01217ff2 CoreFoundation`__CFRunLoopDoSource1 + 146
frame #18: 0x012168da CoreFoundation`__CFRunLoopRun + 2218
frame #19: 0x01215d84 CoreFoundation`CFRunLoopRunSpecific + 212
frame #20: 0x01215c9b CoreFoundation`CFRunLoopRunInMode + 123
frame #21: 0x01f997d8 GraphicsServices`GSEventRunModal + 190
frame #22: 0x01f9988a GraphicsServices`GSEventRun + 103
frame #23: 0x00318626 UIKit`UIApplicationMain + 1163
frame #24: 0x0000274d trainingAttendance`main + 141 at main.m:16
frame #25: 0x000026b5 trainingAttendance`start + 53
這個問題可能是LicenseCell。 – tia
零保留計數是由autorelease池漏...引起的。LicenseCell只是一個.xib – Dustin
您正在使用ARC嗎? – tia