我現在用的樣品在這裏提供的,並使用一個普通的UITableView中的代碼: http://tirania.org/monomac//archive/2012/Jan.html本地堆棧跟蹤崩潰
我以爲一切都很好,直到我增加了很多消息。然後當消息對於屏幕太多時,我看到它崩潰(看起來像是一個單元重用問題)。
我的主要問題是stacktrace幾乎沒有說什麼,所以任何人在普通的UITableView中使用這段代碼,並想分享一些代碼?
這裏是我的GetCell方法和堆棧跟蹤如下:
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) { ChatMessage msg = _items[indexPath.Row]; bool isLeft = msg.User.UserId != _controller._gamebackend.GetLocalUser().UserId; var cell = tableView.DequeueReusableCell (isLeft ? BubbleCell.KeyLeft : BubbleCell.KeyRight) as BubbleCell; if (cell == null) cell = new BubbleCell (isLeft); cell.Update (GetBubbleText(msg)); cell.SelectionStyle = UITableViewCellSelectionStyle.None; return cell; }
2 libsystem_c.dylib 0x31f247ed _sigtramp + 48 Jun 24 00:27:53 unknown 3 Foundation 0x3716a137 probeGC + 62 Jun 24 00:27:53 unknown 4 Foundation 0x3718983b -[NSConcreteMapTable removeObjectForKey:] + 34 Jun 24 00:27:53 unknown 5 UIKit 0x353e13a1 -[_UIImageViewPretiledImageWrapper dealloc] + 80 Jun 24 00:27:53 unknown 6 libobjc.A.dylib 0x34abe175 _objc_rootRelease + 36 Jun 24 00:27:53 unknown 7 libobjc.A.dylib 0x34abfe57 objc_release + 38 Jun 24 00:27:53 unknown 8 libobjc.A.dylib 0x34abeead _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 224 Jun 24 00:27:53 unknown 9 libobjc.A.dylib 0x34abedc9 _objc_autoreleasePoolPop + 12 Jun 24 00:27:53 unknown 10 CoreFoundation 0x32a6dcff _CFAutoreleasePoolPop + 18 Jun 24 00:27:53 unknown 11 QuartzCore 0x31fba91d _ZN2CA7Display11DisplayLink8dispatchEyy + 340 Jun 24 00:27:53 unknown 12 QuartzCore 0x31fba7c5 _ZN2CA7Display16IOMFBDisplayLink8callbackEP21__IOMobileFramebufferyyyPv + 60 Jun 24 00:27:53 unknown 13 IOMobileFramebuffer 0x32ba8001 IOMobileFramebufferVsyncNotifyFunc + 156 Jun 24 00:27:53 unknown 14 IOKit 0x34e3d60d IODispatchCalloutFromCFMessage + 188 Jun 24 00:27:53 unknown 15 CoreFoundation 0x32ae6f13 __CFMachPortPerform + 362 Jun 24 00:27:53 unknown 16 CoreFoundation 0x32af1523 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 38 Jun 24 00:27:53 unknown 17 CoreFoundation 0x32af14c5 __CFRunLoopDoSource1 + 140 Jun 24 00:27:53 unknown 18 CoreFoundation 0x32af0313 __CFRunLoopRun + 1370 Jun 24 00:27:53 unknown 19 CoreFoundation 0x32a734a5 CFRunLoopRunSpecific + 300 Jun 24 00:27:53 unknown 20 CoreFoundation 0x32a7336d CFRunLoopRunInMode + 104 Jun 24 00:27:53 unknown 21 GraphicsServices 0x32bc0439 GSEventRunModal + 136 Jun 24 00:27:53 unknown 22 UIKit 0x35052cd5 UIApplicationMain + 1080
如果我刪除了單元重用代碼,則錯誤消失。我只是一直在創建單元格。但是,即使性能是好的,一切都可以正常工作:-) –