简体   繁体   中英

UITableView crash in iOS 8 on heightForHeaderInSection

UITableView in view controller. While reload the tableView two times and click cell it crash with different errors. I declare in .h interface.

{
UITableView    *tblRestaurantList;
}
// also change to @property (nonatomic, retain)UITableView   *tblRestaurantList;

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{ 
  return 0;
}

error reason : -[UITableViewCell tableView:heightForHeaderInSection:]

error reason : [_UIAppearanceCustomizableClassInfo tableView:heightForHeaderInSection:]

Sometime it shows EXC_BAD_ACCESS(code=EXC_i386_GPFLT) or __NSCFArray or [_CTNativeGlyphStorage tableView:heightForHeaderInSection:] .(With 40 line error message)

I change the height to 1.0f , 0.0 , 0.0001f , 1 ; I don't what happen its run successfully in iOS 7. I saw many questions in StackOverflow but no one post exact answer.

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

*** First throw call stack:
(
0   CoreFoundation                      0x000000011376bf35 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x0000000112589bb7 objc_exception_throw + 45
2   CoreFoundation                      0x000000011377304d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3   CoreFoundation                      0x00000001136cb27c ___forwarding___ + 988
4   CoreFoundation                      0x00000001136cae18 _CF_forwarding_prep_0 + 120
5   UIKit                               0x0000000110ce1f4e -[UITableView _delegateWantsHeaderForSection:] + 261
6   UIKit                               0x0000000110e66983 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 162
7   UIKit                               0x0000000110e6ce45 -[UITableViewRowData rectForFooterInSection:heightCanBeGuessed:] + 320
8   UIKit                               0x0000000110e6cf3a -[UITableViewRowData heightForTable] + 56
9   UIKit                               0x0000000110cbfaf0 -[UITableView _updateContentSize] + 381
10  UIKit                               0x0000000110cdcecd -[UITableView didMoveToWindow] + 65
11  UIKit                               0x0000000110c639a0 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1482
12  UIKit                               0x0000000110c74333 -[UIScrollView _didMoveFromWindow:toWindow:] + 55
13  UIKit                               0x0000000110c6368e -[UIView(Internal) _didMoveFromWindow:toWindow:] + 696
14  UIKit                               0x0000000110c6368e -[UIView(Internal) _didMoveFromWindow:toWindow:] + 696
15  UIKit                               0x0000000110c6368e -[UIView(Internal) _didMoveFromWindow:toWindow:] + 696
16  UIKit                               0x0000000110c5c112 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 125
17  UIKit                               0x0000000110c5c086 -[UIView(Hierarchy) _postMovedFromSuperview:] + 437
18  UIKit                               0x0000000110c65f4b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1604
19  UIKit                               0x0000000110be4bf1 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke + 2030
20  UIKit                               0x0000000110c605ce +[UIView(Animation) performWithoutAnimation:] + 65
21  UIKit                               0x0000000110be4072 -[_UINavigationParallaxTransition animateTransition:] + 1225
22  UIKit                               0x0000000110d38e6c -[UINavigationController _startCustomTransition:] + 3038
23  UIKit                               0x0000000110d443fe -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
24  UIKit                               0x0000000110d44f47 -[UINavigationController __viewWillLayoutSubviews] + 43
25  UIKit                               0x0000000110e8a509 -[UILayoutContainerView layoutSubviews] + 202
26  UIKit                               0x0000000110c68973 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
27  QuartzCore                          0x0000000110347de8 -[CALayer layoutSublayers] + 150
28  QuartzCore                          0x000000011033ca0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
29  QuartzCore                          0x000000011033c87e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
30  QuartzCore                          0x00000001102aa63e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
31  QuartzCore                          0x00000001102ab74a _ZN2CA11Transaction6commitEv + 390
32  QuartzCore                          0x00000001102abdb5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
33  CoreFoundation                      0x00000001136a0dc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
34  CoreFoundation                      0x00000001136a0d20 __CFRunLoopDoObservers + 368
35  CoreFoundation                      0x0000000113696b53 __CFRunLoopRun + 1123
36  CoreFoundation                      0x0000000113696486 CFRunLoopRunSpecific + 470
37  GraphicsServices                    0x00000001144d09f0 GSEventRunModal + 161
38  UIKit                               0x0000000110bef420 UIApplicationMain + 1282
39  Restaurant                          0x000000010f466193 main + 115
40  libdyld.dylib                       0x0000000112c10145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

I am using OS X Yosemite ver 10.10, xcode Version 6.1 (6A1052d), iPhone simulator iOS 8.1 (12B411).

Thanks in Advance

But why you put 0 in height ??

we can't put 0 here . if you do not want to put height for section, then don't put 0 in height.

This should be some value

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{ 
  return 4; // something like this 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM