Eri*_*k B 8 cocoa-touch objective-c uitableview uikit ios
因未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [SomeClassNameController tableView:heightForHeaderInSection:]:无法识别的选择器发送到实例0x1805f1f0'
除非我误解了文档,否则这是不可能的.如果tableView:heightForHeaderInSection:未在委托中实现,则应使用存储的任何值sectionHeaderHeight.在任何情况下都不应该呼吁tableView:heightForHeaderInSection:没有实现它的代表.
这是正确的还是我实际上误解了文档?
编辑:按要求堆栈跟踪.
Last Exception Backtrace:
0 CoreFoundation 0x30443e83 __exceptionPreprocess + 131
1 libobjc.A.dylib 0x3aadf6c7 _objc_exception_throw + 39
2 CoreFoundation 0x304477b7 -[NSObject(NSObject) doesNotRecognizeSelector:] + 203
3 CoreFoundation 0x30445f4d ___forwarding___ + 353
4 CoreFoundation 0x30394dc8 __CF_forwarding_prep_0 + 24
5 UIKit 0x32cabfff -[UISectionRowData heightForHeaderInSection:canGuess:] + 123
6 UIKit 0x32cabf2b -[UITableViewRowData rectForHeaderInSection:heightCanBeGuessed:] + 391
7 UIKit 0x32dc83b3 -[_UITableViewUpdateSupport(Private) _setupAnimationsForExistingHeadersAndFooters] + 1603
8 UIKit 0x32dc37db -[_UITableViewUpdateSupport _setupAnimations] + 187
9 UIKit 0x32dc328b -[UITableView _updateWithItems:updateSupport:] + 1363
10 UIKit 0x32d9b397 -[UITableView _endCellAnimationsWithContext:] + 8019
11 appname 0x000704a9 -[SomeClassNameView layoutSubviews] (SomeClassNameView.m:47)
12 UIKit 0x32bc8353 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 347
13 QuartzCore 0x3284e943 -[CALayer layoutSublayers] + 143
14 QuartzCore 0x3284a167 CA::Layer::layout_if_needed(CA::Transaction*) + 351
15 QuartzCore 0x32849ff9 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 17
16 QuartzCore 0x32849a0d CA::Context::commit_transaction(CA::Transaction*) + 229
17 QuartzCore 0x3284981f CA::Transaction::commit() + 315
18 QuartzCore 0x3284354d CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 57
19 CoreFoundation 0x3040ef69 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 21
20 CoreFoundation 0x3040c8f7 __CFRunLoopDoObservers + 287
21 CoreFoundation 0x3040cc43 __CFRunLoopRun + 739
22 CoreFoundation 0x30377471 _CFRunLoopRunSpecific + 525
23 CoreFoundation 0x30377253 _CFRunLoopRunInMode + 107
24 GraphicsServices 0x350782eb _GSEventRunModal + 139
25 UIKit 0x32c2c845 _UIApplicationMain + 1137
26 appname 0x00386767 main (main.m:32)
27 appname 0x00020e48 start + 40
Run Code Online (Sandbox Code Playgroud)
来自文档
tableView:viewForHeaderInSection:
...
Discussion
The returned object can be a UILabel or UIImageView object, as well as a custom view.
This method only works correctly when tableView:heightForHeaderInSection: is also implemented.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Run Code Online (Sandbox Code Playgroud)
显然苹果将“无法正常工作”解释为“可能会崩溃”。