我有一个以ViewController作为数据源和委托的UITableView。在同一个XIB中,我有一个自定义单元格用于我的搜索栏。表格视图中的第一个单元格是此单元格。偶尔,我会遇到一个崩溃,但有以下异常:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x5d76840'Gdb显示这实际上是我的搜索单元格,并且它是tableview的子级。此外,进一步的检查显示数据源实际上正确地指向了我的视图控制器,而不是搜索栏单元格。基于此,UIKit似乎只是将消息发送到了错误的目标。有人见过这样的东西吗?会不会只是模拟器中的一个问题?
全栈:
*** Call stack at first throw:
(
0 CoreFoundation 0x012955a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x013e9313 objc_exception_throw + 44
2 CoreFoundation 0x012970bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x01206966 ___forwarding___ + 966
4 CoreFoundation 0x01206522 _CF_forwarding_prep_0 + 50
5 UIKit 0x006a26ff -[UITableViewRowData(UITableViewRowDataPrivate) _updateNumSections] + 111
6 UIKit 0x006a23b0 -[UITableViewRowData invalidateAllSections] + 66
7 UIKit 0x00559d23 -[UITableView(_UITableViewPrivate) _updateRowData] + 113
8 UIKit 0x0055565c -[UITableView noteNumberOfRowsChanged] + 105
9 UIKit 0x00562708 -[UITableView reloadData] + 773
10 Foundation 0x00c6e94e __NSThreadPerformPerform + 251
11 CoreFoundation 0x012768ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
12 CoreFoundation 0x011d488b __CFRunLoopDoSources0 + 571
13 CoreFoundation 0x011d3d86 __CFRunLoopRun + 470
14 CoreFoundation 0x011d3840 CFRunLoopRunSpecific + 208
15 CoreFoundation 0x011d3761 CFRunLoopRunInMode + 97
16 GraphicsServices 0x01d3e1c4 GSEventRunModal + 217
17 GraphicsServices 0x01d3e289 GSEventRun + 115
18 UIKit 0x004f5c93 UIApplicationMain + 1160
19 iPanopto 0x000020f9 main + 121
20 iPanopto 0x00002075 start + 53
)发布于 2011-12-05 07:00:28
当UITableViewController没有正确地连接到NIB时,我遇到了这个问题...或者在NIB文件中没有定义特定的自定义单元格类。
发布于 2013-11-29 17:07:15
您的UITableView的父视图可能会在幕后发布,因为有了ARC。我也遇到过这个问题,最终被this answer带上了正轨(谢谢托马斯!)。请注意,这个问题的根源可能存在于实际表所在位置的上游。
https://stackoverflow.com/questions/8379272
复制相似问题