Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`tableView:heightForHeaderInSection:` called on delegate that doesn't implement it

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SomeClassNameController tableView:heightForHeaderInSection:]: unrecognized selector sent to instance 0x1805f1f0'

Unless I've misunderstood the documentation, this shouldn't be possible. If tableView:heightForHeaderInSection: isn't implemented in the delegate it should use whatever value that is stored in sectionHeaderHeight. Under no circumstances should it call tableView:heightForHeaderInSection: on a delegate that doesn't implement it.

Is this correct or did I in fact misunderstand the documentation?

EDIT: Stack trace as requested.

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
like image 590
Erik B Avatar asked Feb 07 '14 14:02

Erik B


2 Answers

Any chance you're using the Apptimize framework for A/B testing? Introducing it into my project causes it to cause the UITableView delegate responding checks to stop working, and makes the UITableView issue you're describing happen. If I remove the framework, it stops happening.

like image 154
Zac West Avatar answered Nov 15 '22 05:11

Zac West


From the docs

Special Considerations
Prior to iOS 5.0, table views would automatically resize the heights of headers to 0 for sections where tableView:viewForHeaderInSection: returned a nil view. In iOS 5.0 and later, you must return the actual height for each section header in this method.

Is this change causing the issue.

Are you creating the table view from code or xib? If it is xib , I am sure there is some default value for section header height, but what if you are creating it through code. May be when running in compatibility mode there is some problem with default value of 'sectionHeaderHeight'.

like image 23
Rajesh Avatar answered Nov 15 '22 05:11

Rajesh