`tableView: heightForHeaderInSection:` calling a delegate that does not implement it

Application termination due to an uncaught exception "NSInvalidArgumentException", reason: '- [SomeClassNameController tableView: heightForHeaderInSection:]: unrecognized selector sent to instance 0x1805f1f0'

If I misunderstood the documentation, this should not be possible. If tableView:heightForHeaderInSection: not used in the delegate, it must use any value that is stored in sectionHeaderHeight . Under no circumstances should you call tableView:heightForHeaderInSection: delegate that does not implement it.

Is this correct or did I really not understand the documentation?

EDIT: Trace the stack on request.

 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 
+8
ios objective-c cocoa-touch uikit uitableview
source share
4 answers

Is there any chance of using the Apptimize framework to test A / B? Introducing it in my project, it causes the UITableView delegate response to turn off to stop working, and makes the UITableView problem you are describing. If I remove the framework, it will stop.

+4
source share

From the documents

 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. 

This change causes a problem.

Do you create a table view from code or xib? If it is xib, I am sure that there is a default value for the height of the section header, but what if you create it through code. Maybe when working in compatibility mode there is some problem with the default value of 'sectionHeaderHeight'.

+1
source share

From the documents

 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. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

Apparently, Apple interprets "not working correctly" because "it may crash."

0
source share

I am not an encoder, but delegate methods are always running using the default encoding if there is no override. Simply, if there is an override, the code in the override is executed instead of the default value.

 -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 

In this case, the method expects the address of the Tableview and NSInteger instance representing the partition, an invalid value in one of them will throw an exception ....

I would focus my debugging efforts on the state of the table or section before the exception occurs ....

In this case, I would encode the delegate method, set a breakpoint and see what is passed to it.

0
source share

All Articles