2011-10-27 80 views
0

我只使用-reloadData來重新加載我的表,但由於某種原因它每次加載這個表時崩潰。這僅僅是在應用程序中很多表都是由同一個視圖 - 控制器超處理中的一種:與桌面視圖重新加載有關的奇怪崩潰

Thread 0 name: Dispatch queue: com.apple.main-thread 
Thread 0 Crashed: 
0 libobjc.A.dylib      0x321effbc objc_msgSend + 16 
1 UIKit        0x31abd9c4 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 540 
2 UIKit        0x31abcaa2 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1070 
3 UIKit        0x31abc22c -[UITableView layoutSubviews] + 200 
4 UIKit        0x31a60d44 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 176 
5 CoreFoundation      0x36de4224 -[NSObject performSelector:withObject:] + 36 
6 QuartzCore       0x317ab37a -[CALayer layoutSublayers] + 210 
7 QuartzCore       0x317aaf92 CA::Layer::layout_if_needed(CA::Transaction*) + 210 
8 QuartzCore       0x317af114 CA::Context::commit_transaction(CA::Transaction*) + 220 
9 QuartzCore       0x317aee50 CA::Transaction::commit() + 308 
10 QuartzCore       0x317a6d7e CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 50 
11 CoreFoundation      0x36e59b44 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 12 
12 CoreFoundation      0x36e57d80 __CFRunLoopDoObservers + 252 
13 CoreFoundation      0x36e580da __CFRunLoopRun + 754 
14 CoreFoundation      0x36ddb4d6 CFRunLoopRunSpecific + 294 
15 CoreFoundation      0x36ddb39e CFRunLoopRunInMode + 98 
16 GraphicsServices     0x32ab6fe6 GSEventRunModal + 150 
17 UIKit        0x31a8b73c UIApplicationMain + 1084 

的堆棧跟蹤的步驟都不是我們直接的代碼,所以我迷路了。爲什麼會在這裏崩潰?

+0

你什麼時候重新加載表?例如,在viewWillAppear或一些數據下載後等。 –

+0

我重新加載在-viewDidLoad,然後當我收到「fetchedResultsControllerDidChangeContent」通知。 –

+0

嘗試設置NSZombieEnabled YES並查看您是否嘗試訪問發佈的對象。這可能與重新加載tableview數據無關。嘗試訪問發佈的對象會再現類似的問題。 – 0x8badf00d

回答

2

確保您的TableView的委託和數據源在viewControllers的dealloc方法中設置爲零。當系統試圖調用CellForRow ....對於被破壞的tableview時,我完全一樣。

1

我跑到這個相同的蹤跡使用筆尖實例化行單元格,並發現我意外地從壞筆尖參考實例化單元格。我被實例化,像這樣的小區在上表中的數據源委託的cellForRowAtIndexPath回調:

static NSString *CellIdentifier = @"CustomCellIdentifier"; 
CustomCell *cell = (CustomCell*)[aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) 
{ 
    [self.cellNib instantiateWithOwner:self options:nil]; 
    cell = tmpCell; 
    self.tmpCell = nil; 
} 

要解決我在viewDidLoad中確信我創建cellNib:

self.cellNib = [UINib nibWithNibName:@"CustomCellNib" bundle:nil]; 

而且在viewDidUnload,殺參考它(這是最重要的一步):

self.cellNib = nil;