I have a custom view whose init method is as below. This used to work fine in Xcode 9.1 with swift 4. Today I updated to Xcode 9.3 and set the project base to swift 4.1 and it started crashing in this init method.
init(frame: CGRect, detailDic: [[String:AnyObject]], parentView:UIView)
{
super.init(frame:frame)
self.view = Utilities.loadViewFromNib(“MyScoreView", atIndex: 0, aClass: type(of: self),parent:self) as! UIView
self.view.frame = frame
self.view.autoresizingMask = [UIViewAutoresizing.flexibleWidth, UIViewAutoresizing.flexibleHeight]
self.view.isHidden = true
finalScoreTable.register(UINib(nibName: “MyScoreTableViewCell", bundle: nil), forCellReuseIdentifier: "scoreCell")
addSubview(self.view)
parentView.addSubview(self) //Crashes here
finalScoreTable.tableFooterView = UIView()
}
Crash stack trace
*** First throw call stack:
(
0 CoreFoundation 0x0000000104a471e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x0000000103651031 objc_exception_throw + 48
2 CoreFoundation 0x0000000104ac8784 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 UIKit 0x00000001066ea73b -[UIResponder doesNotRecognizeSelector:] + 295
4 CoreFoundation 0x00000001049c9898 ___forwarding___ + 1432
5 CoreFoundation 0x00000001049c9278 _CF_forwarding_prep_0 + 120
6 UIKit 0x0000000106626851 -[UITableView _numberOfRowsInSection:] + 62
7 UIKit 0x00000001068d5e5b -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 2631
8 UIKit 0x00000001068dc219 -[UITableViewRowData rectForFooterInSection:heightCanBeGuessed:] + 487
9 UIKit 0x00000001068dc37f -[UITableViewRowData heightForTable] + 61
10 UIKit 0x00000001065d684e -[UITableView _updateContentSize] + 365
11 UIKit 0x0000000106605a8f -[UITableView _rebuildGeometry] + 66
12 UIKit 0x0000000106603583 -[UITableView didMoveToWindow] + 145
13 UIKit 0x0000000106581f55 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1718
14 UIKit 0x000000010659b73e -[UIScrollView _didMoveFromWindow:toWindow:] + 84
15 UIKit 0x0000000106581b98 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 761
16 UIKit 0x0000000106581b98 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 761
17 UIKit 0x0000000106574114 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 151
18 UIKit 0x0000000106573fea -[UIView(Hierarchy) _postMovedFromSuperview:] + 808
19 UIKit 0x0000000106584a2b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1940
20 MySampleApp 0x0000000102649ec7 _T017MySampleApp14MyScoreViewCACSC6CGRectV5frame_Says10DictionaryVySSyXlGG13playerDetailsSo6UIViewC06parentF0tcfc + 4343
21 MySampleApp 0x0000000102648dc7 _T017MySampleApp14MyScoreViewCACSC6CGRectV5frame_Says10DictionaryVySSyXlGG13playerDetailsSo6UIViewC06parentF0tcfC + 87
22 MySampleApp 0x00000001026371b8 _T017MySampleApp22MainGameViewControllerC14showScoreAlertySo5TimerCF + 2200
23 MySampleApp 0x000000010263784c _T017MySampleApp22MainGameViewControllerC14showScoreAlertySo5TimerCFTo + 60
24 Foundation 0x00000001030bb4dd __NSFireTimer + 83
25 CoreFoundation 0x00000001049d6e64 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
26 CoreFoundation 0x00000001049d6a52 __CFRunLoopDoTimer + 1026
27 CoreFoundation 0x00000001049d660a __CFRunLoopDoTimers + 266
28 CoreFoundation 0x00000001049cde4c __CFRunLoopRun + 2252
29 CoreFoundation 0x00000001049cd30b CFRunLoopRunSpecific + 635
30 GraphicsServices 0x000000010c816a73 GSEventRunModal + 62
31 UIKit 0x00000001064bc0b7 UIApplicationMain + 159
32 MySampleApp 0x00000001026580e7 main + 55
33 libdyld.dylib 0x00000001093d4955 start + 1
34 ??? 0x0000000000000001 0x0 + 1
)
Related
Everything was working fine on xcode 7.3.1, Than I have to add braintree 3ds sdk which is supported on xcode 8. So, I migrated the code to xcode 8 and than xcode 9. Now, build working fine on below IOS 11 but on ios 11 and above app is crashing before opening new main screen. I am new to Ios please help.
it's crashing on this line :
let vc = storyboard?.instantiateViewController(withIdentifier: "KbNav") as! KabNavigationController
2018-08-30 12:25:52.730641+0500 Kab[2970:32711] *** Assertion failure in
-[_UINavigationBarVisualProviderModernIOS _contentViewFittingHeight],
/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-
3698.33.6/_UINavigationBarVisualProviderModernIOS.m:569
2018-08-30 12:25:52.769549+0500 Kab[2970:32711] *** Terminating app due
to uncaught exception 'NSInternalInconsistencyException', reason: 'Sigh.
Contentview size is zero.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000115da712b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000114d50f41 objc_exception_throw + 48
2 CoreFoundation 0x0000000115dac2f2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00000001147f1d69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x00000001131382f5 -[_UINavigationBarVisualProviderModernIOS _contentViewFittingHeight] + 265
5 UIKit 0x0000000112eb65e0 -[UINavigationItem _desiredHeightForBarMetrics:defaultHeightBlock:] + 90
6 UIKit 0x000000011313afa1 -[_UINavigationBarVisualProviderModernIOS heightRangeFittingWidth:] + 412
7 UIKit 0x000000011264a0ed -[UINavigationBar _heightRangeForNavigationItem:fittingWidth:] + 210
8 UIKit 0x0000000112726a98 -[UINavigationController _intrinsicNavigationBarHeightRangeForViewController:] + 187
9 UIKit 0x00000001127269b6 -[UINavigationController _preferredHeightForHidingNavigationBarForViewController:] + 628
10 UIKit 0x000000011271688f -[UINavigationController _positionNavigationBarHidden:edge:initialOffset:] + 356
11 UIKit 0x0000000112716cf8 -[UINavigationController _positionNavigationBarHidden:edge:] + 388
12 UIKit 0x000000011271e555 -[UINavigationController loadView] + 243
13 UIKit 0x00000001126e105c -[UIViewController loadViewIfRequired] + 195
14 UIKit 0x00000001126e18b9 -[UIViewController view] + 27
15 Kab 0x000000010f00faea -[SlideNavigationController setEnableShadow:] + 74
16 Kab 0x000000010f00d494 -[SlideNavigationController setup] + 244
17 Kab 0x000000010f00d1d1 -[SlideNavigationController initWithCoder:] + 145
18 Kab 0x000000010f20e1d6 _T08Kab0A20NavigationControllerCACSgSo7NSCoderC5coder_tcfc + 214
19 Kab 0x000000010f20e29f _T08Kab0A20NavigationControllerCACSgSo7NSCoderC5coder_tcfcTo + 47
20 UIKit 0x00000001129ca4c8 -[UIClassSwapper initWithCoder:] + 246
21 UIKit 0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
22 UIKit 0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
23 UIKit 0x000000011264675a -[UINavigationBar initWithCoder:] + 753
24 UIKit 0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
25 UIKit 0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
26 UIKit 0x0000000112eb15f2 -[UINavigationItem initWithCoder:] + 1018
27 UIKit 0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
28 UIKit 0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
29 UIKit 0x00000001126dc053 -[UIViewController initWithCoder:] + 432
30 Kab 0x000000010f29a6a8 _T08Kab18HomeViewControllerCACSgSo7NSCoderC5coder_tcfc + 7704
31 Kab 0x000000010f29a77f _T08Kab18HomeViewControllerCACSgSo7NSCoderC5coder_tcfcTo + 47
32 UIKit 0x00000001129ca4c8 -[UIClassSwapper initWithCoder:] + 246
33 UIKit 0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
34 UIKit 0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
35 UIKit 0x00000001129ca194 -[UIRuntimeConnection initWithCoder:] + 178
36 UIKit 0x00000001129ca8d0 -[UIRuntimeEventConnection initWithCoder:] + 59
37 UIKit 0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
38 UIKit 0x0000000112c1f2a7 UINibDecoderDecodeObjectForValue + 1118
39 UIKit 0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
40 UIKit 0x00000001129c9391 -[UINib instantiateWithOwner:options:] + 1262
41 UIKit 0x0000000112e59fc2 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181
42 Kab 0x000000010f135a7b _T08Kabr24LaunchTourViewControllerC4skipyyXlF + 219
43 Kab 0x000000010f136118 _T08Kab24LaunchTourViewControllerC4skipyyXlFTo + 56
44 UIKit 0x000000011253a972 -[UIApplication sendAction:to:from:forEvent:] + 83
45 UIKit 0x00000001126b9c3c -[UIControl sendAction:to:forEvent:] + 67
46 UIKit 0x00000001126b9f59 -[UIControl _sendActionsForEvents:withEvent:] + 450
47 UIKit 0x00000001126b8e86 -[UIControl touchesEnded:withEvent:] + 618
48 UIKit 0x00000001125b0807 -[UIWindow _sendTouchesForEvent:] + 2807
49 UIKit 0x00000001125b1f2a -[UIWindow sendEvent:] + 4124
50 UIKit 0x0000000112555365 -[UIApplication sendEvent:] + 352
51 UIKit 0x0000000112ea1a1d __dispatchPreprocessedEventFromEventQueue + 2809
52 UIKit 0x0000000112ea4672 __handleEventQueueInternal + 5957
53 CoreFoundation 0x0000000115d4a101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
54 CoreFoundation 0x0000000115de9f71 __CFRunLoopDoSource0 + 81
55 CoreFoundation 0x0000000115d2ea19 __CFRunLoopDoSources0 + 185
56 CoreFoundation 0x0000000115d2dfff __CFRunLoopRun + 1279
57 CoreFoundation 0x0000000115d2d889 CFRunLoopRunSpecific + 409
58 GraphicsServices 0x0000000118d049c6 GSEventRunModal + 62
59 UIKit 0x00000001125395d6 UIApplicationMain + 159
60 Kab 0x000000010f191137 main + 55
61 libdyld.dylib 0x0000000117112d81 start + 1
62 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
KbNavigationController
class KabNavigationController: SlideNavigationController {
var menuItems: [(id: String, image: String, text: String)] = []
override func viewDidLoad() {
self.leftMenu = self.storyboard?.instantiateViewController(withIdentifier: "MenuViewController")
navigationBar.barTintColor = Theme.DarkGray
navigationBar.tintColor = Theme.White
navigationBar.barStyle = UIBarStyle.black
// Popup Navigation Bar
STPopupNavigationBar.appearance().isHidden = true
}
}
I have searched and debug my code alot keep in mind always enable exception break points to trigger exactly which line causing the crash. You can learn it from this Exception Breakpoint in Xcode . I found my solution here https://github.com/aryaxt/iOS-Slide-Menu/issues/250.
move these two lines from setup function to viewWillLayoutSubviews of Slide Menu.
//moved this from the `setup` function:
self.enableShadow = YES;
self.enableSwipeGesture = YES;
I'm using JSQMessageViewController for chat UI. The JSQMessageViewController implements UIScrollViewDelegate, and having scrollViewDidScroll: function.
And then I subclass JSQMessageViewController into MessagesVc. The scrollViewDidScroll: is called correctly without I even need to override it in the MessagesVc.
And then I create another subclass of JSQMessageViewController as JSQBaseViewController. I override the scrollViewDidScroll: here, and also calling super.scrollViewDidScroll: inside it. My MessagesVc now is a subclass of JSQBaseViewController instead of JSQMessageViewController.
But when I ran the app, now it raise the error: reason: '-[MyApps.MessagesVc scrollViewDidScroll:]: unrecognized selector sent to instance 0x7fe5ed00aa00'. Why is this happened? I don't think this error is supposed to happen, right?
EDIT: I tried to override scrollViewDidScroll: in MessagesVc and it still doesn't work.
Here is the circumstances of the implementation of scrollViewDidScroll: override:
import JSQMessageViewController
class JSQBaseViewController : JSQMessageViewController {
...
}
extension JSQBaseViewController {
override func scrollViewDidScroll(_ scrollView: UIScrollView) {
super.scrollViewDidScroll(scrollView)
...
}
}
class MessagesVc : JSQBaseViewController {
...
// still no override implementation of scrollViewDidScroll here
}
Call stack:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MyApps.MessagesVc scrollViewDidScroll:]: unrecognized selector sent to instance 0x7fe5ed00aa00'
*** First throw call stack:
(
0 CoreFoundation 0x00000001084f01e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x0000000107b85031 objc_exception_throw + 48
2 CoreFoundation 0x0000000108571784 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 UIKit 0x00000001098df73b -[UIResponder doesNotRecognizeSelector:] + 295
4 CoreFoundation 0x00000001084725f8 ___forwarding___ + 760
5 CoreFoundation 0x0000000108472278 _CF_forwarding_prep_0 + 120
6 MyApps 0x0000000105362eb3 _T06MyApps21JSQBaseViewControllerC06scrollC9DidScrollySo08UIScrollC0CF + 131
7 MyApps 0x0000000105363e2c _T06MyApps21JSQBaseViewControllerC06scrollC9DidScrollySo08UIScrollC0CFTo + 60
8 UIKit 0x00000001097a8bcf -[UIScrollView(UIScrollViewInternal) _notifyDidScroll] + 66
9 UIKit 0x000000010978eb87 -[UIScrollView setContentOffset:] + 468
10 UIKit 0x00000001097ac854 -[UIScrollView(UIScrollViewInternal) _setContentOffset:animated:animationCurve:animationAdjustsForContentOffsetDelta:animation:] + 1022
11 UIKit 0x000000010a187f35 -[UICollectionView setContentOffset:animated:] + 350
12 JSQMessagesViewController 0x0000000106f842e5 -[JSQMessagesViewController scrollToIndexPath:animated:] + 2165
13 JSQMessagesViewController 0x0000000106f83a59 -[JSQMessagesViewController scrollToBottomAnimated:] + 265
14 JSQMessagesViewController 0x0000000106f83714 -[JSQMessagesViewController finishSendingMessageAnimated:] + 660
15 JSQMessagesViewController 0x0000000106f83470 -[JSQMessagesViewController finishSendingMessage] + 48
16 MyApps 0x000000010584350b _T06MyApps10MessagesVcC13reloadDisplayyyF + 27
17 MyApps 0x0000000105843544 _T06MyApps10MessagesVcC13reloadDisplayyyFTo + 36
18 MyApps 0x000000010561f713 _T06MyApps10MessagesVcC10dataSourceSayAA9MyMessageCGSgvW + 35
19 MyApps 0x000000010561f6c9 _T06MyApps10MessagesVcC10dataSourceSayAA9MyMessageCGSgvs + 233
20 MyApps 0x0000000105842fad _T06MyApps10MessagesVcC10reloadDatayyF + 717
21 MyApps 0x00000001058434d4 _T06MyApps10MessagesVcC10reloadDatayyFTo + 36
22 MyApps 0x00000001055d4744 _T06MyApps10MessagesVcC11viewDidLoadyyF + 2148
23 MyApps 0x00000001055d5a94 _T06MyApps10MessagesVcC11viewDidLoadyyFTo + 36
24 UIKit 0x0000000109855191 -[UIViewController loadViewIfRequired] + 1215
25 UIKit 0x00000001098555d4 -[UIViewController view] + 27
26 UIKit 0x0000000109886c6e -[UINavigationController _startCustomTransition:] + 945
27 UIKit 0x000000010989d5e2 -[UINavigationController _startDeferredTransitionIfNeeded:] + 714
28 UIKit 0x000000010989e8cc -[UINavigationController __viewWillLayoutSubviews] + 150
29 UIKit 0x0000000109af6bd7 -[UILayoutContainerView layoutSubviews] + 231
30 UIKit 0x0000000109780808 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1515
31 QuartzCore 0x000000010931061a -[CALayer layoutSublayers] + 177
32 QuartzCore 0x000000010931482b _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395
33 QuartzCore 0x000000010929b29f _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 343
34 QuartzCore 0x00000001092c8940 _ZN2CA11Transaction6commitEv + 568
35 UIKit 0x00000001096d9f8c _afterCACommitHandler + 272
36 CoreFoundation 0x0000000108492607 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
37 CoreFoundation 0x000000010849255e __CFRunLoopDoObservers + 430
38 CoreFoundation 0x0000000108476b81 __CFRunLoopRun + 1537
39 CoreFoundation 0x000000010847630b CFRunLoopRunSpecific + 635
40 GraphicsServices 0x00000001104bea73 GSEventRunModal + 62
41 UIKit 0x00000001096b10b7 UIApplicationMain + 159
42 MyApps 0x0000000105755ac7 main + 55
43 libdyld.dylib 0x000000010cf0e955 start + 1
44 ??? 0x0000000000000001 0x0 + 1
)
My app keeps crashing whenever I tap on a UITextField that I add to my view programmatically. Here is the stack trace if it is of any help:
'NSInvalidArgumentException', reason: '-[Clifford_Bradford.OtherVehiclesViewController numOfOtherVehiclesUpdated:]: unrecognized selector sent to instance 0x7fd92a57f8d0'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107e5dc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001099c8bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000107e650ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000107dbb13c ___forwarding___ + 988
4 CoreFoundation 0x0000000107dbacd8 _CF_forwarding_prep_0 + 120
5 UIKit 0x00000001086fdd62 -[UIApplication sendAction:to:from:forEvent:] + 75
6 UIKit 0x000000010880f50a -[UIControl _sendActionsForEvents:withEvent:] + 467
7 UIKit 0x0000000108e26d39 -[UITextField _resignFirstResponder] + 256
8 UIKit 0x0000000108e26bab -[UITextField _finishResignFirstResponder] + 45
9 UIKit 0x000000010888078b -[UIResponder resignFirstResponder] + 114
10 UIKit 0x0000000108e26b04 -[UITextField resignFirstResponder] + 114
11 UIKit 0x0000000108880575 -[UIResponder becomeFirstResponder] + 284
12 UIKit 0x000000010876fb81 -[UIView(Hierarchy) becomeFirstResponder] + 99
13 UIKit 0x0000000108e26307 -[UITextField becomeFirstResponder] + 51
14 UIKit 0x0000000108ab5d4e -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 177
15 UIKit 0x0000000108ab7dc0 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 2263
16 UIKit 0x0000000108aad656 _UIGestureRecognizerSendActions + 262
17 UIKit 0x0000000108aac2f9 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 532
18 UIKit 0x0000000108ab0f16 ___UIGestureRecognizerUpdate_block_invoke662 + 51
19 UIKit 0x0000000108ab0e12 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 254
20 UIKit 0x0000000108aa6e8d _UIGestureRecognizerUpdate + 2796
21 UIKit 0x000000010874a646 -[UIWindow _sendGesturesForEvent:] + 1041
22 UIKit 0x000000010874b272 -[UIWindow sendEvent:] + 666
23 UIKit 0x0000000108711541 -[UIApplication sendEvent:] + 246
24 UIKit 0x000000010871ecdc _UIApplicationHandleEventFromQueueEvent + 18265
25 UIKit 0x00000001086f959c _UIApplicationHandleEventQueue + 2066
26 CoreFoundation 0x0000000107d91431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
27 CoreFoundation 0x0000000107d872fd __CFRunLoopDoSources0 + 269
28 CoreFoundation 0x0000000107d86934 __CFRunLoopRun + 868
29 CoreFoundation 0x0000000107d86366 CFRunLoopRunSpecific + 470
30 GraphicsServices 0x000000010be31a3e GSEventRunModal + 161
31 UIKit 0x00000001086fc8c0 UIApplicationMain + 1282
32 Clifford Bradford 0x0000000107c33bb7 main + 135
33 libdyld.dylib 0x000000010a0fe145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException`.
It just points me to the first line of the AppDelegate.swift which doesn't really help me. Here is the corresponding code that adds the textField to the view. I would like to add that the contView is inside a scrollView.
var otherVehiclePlateNum:UITextField = UITextField(frame: CGRectMake(carLabel.bounds.origin.x + 15, carLabel.frame.maxY + 10, self.contView.frame.width - 30, 25))
otherVehiclePlateNum.placeholder = "TEST"
self.contView.addSubview(otherVehiclePlateNum)
Thanks so much for your help, I've been stuck on this.
Look at the first line: Does the method numOfOtherVehiclesUpdated: actually exist in the OtherVehiclesViewController class? Make sure that that if you're calling any #selectors that the colon matches the signature (i.e., you may have a numOfOtherVehiclesUpdated method, which isn't the same as numOfOtherVehiclesUpdated: which takes a parameter).
Look there first - you may be calling that by accident
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
}
I have an App written for iOS 6 that uses UICollectionViewController, the app works fine but when I tried to compile in Xcode 5 I get the error bellow.
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'layout cannot be nil in setCollectionViewLayout:'...
I tried to use this solution but I keep getting the same error. Any ideas?
CollectionViewLayout *layout = [[CollectionViewLayout alloc] init];
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
[self.collectionView registerClass:[Cell class] forCellWithReuseIdentifier:ItemIdentifier];
[self.collectionView registerClass:[HeaderCollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:#"HeaderView"];
self.collectionLayout.headerReferenceSize = CGSizeMake(0, 50);
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
self.collectionView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
self.collectionLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
//Stack trace
2013-10-01 14:15:37.140 MemberCatalog[10841:a0b] *** Assertion failure in -[UICollectionView setCollectionViewLayout:], /SourceCache/UIKit_Sim/UIKit-2903.2/UICollectionView.m:2001
2013-10-01 14:15:37.186 MemberCatalog[10841:a0b] Uncaught exception: NSInternalInconsistencyException
Reason: layout cannot be nil in setCollectionViewLayout:
User Info: (null)
Call Stack: (
0 CoreFoundation 0x031e75e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x02c548b6 objc_exception_throw + 44
2 CoreFoundation 0x031e7448 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0029923e -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x00cdeba3 -[UICollectionView setCollectionViewLayout:] + 156
5 UIKit 0x00cfcd7b -[UICollectionViewControllerWrapperView didMoveToSuperview] + 462
6 UIKit 0x007261a6 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 472
7 UIKit 0x00725ef8 -[UIView(Hierarchy) _postMovedFromSuperview:] + 260
8 UIKit 0x00731031 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1847
9 UIKit 0x00724521 -[UIView(Hierarchy) addSubview:] + 56
10 UIKit 0x007d66eb +[UIViewControllerWrapperView wrapperViewForView:wrapperFrame:viewFrame:] + 382
11 UIKit 0x0080c867 -[UITabBarController _wrapperViewForViewController:] + 221
12 UIKit 0x00813a60 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 441
13 UIKit 0x00813262 -[UITabBarController transitionFromViewController:toViewController:] + 63
14 UIKit 0x0080f64b -[UITabBarController _setSelectedViewController:] + 279
15 UIKit 0x0080f470 -[UITabBarController setSelectedIndex:] + 261
16 MemberCatalog 0x000aa9f8 -[MainViewController updateTabBar:] + 584
17 MemberCatalog 0x000ab872 -[MainViewController showCategory::] + 3538
18 MemberCatalog 0x000abe30 -[MainViewController menuButtonTap:] + 1296
19 libobjc.A.dylib 0x02c66874 -[NSObject performSelector:withObject:withObject:] + 77
20 UIKit 0x006cac8c -[UIApplication sendAction:to:from:forEvent:] + 108
21 UIKit 0x006cac18 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
22 UIKit 0x007c26d9 -[UIControl sendAction:to:forEvent:] + 66
23 UIKit 0x007c2a9c -[UIControl _sendActionsForEvents:withEvent:] + 577
24 UIKit 0x007c1d4b -[UIControl touchesEnded:withEvent:] + 641
25 UIKit 0x007080cd -[UIWindow _sendTouchesForEvent:] + 852
26 UIKit 0x00708d34 -[UIWindow sendEvent:] + 1232
27 UIKit 0x006dca36 -[UIApplication sendEvent:] + 242
28 UIKit 0x006c6d9f _UIApplicationHandleEventQueue + 11421
29 CoreFoundation 0x031708af __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
30 CoreFoundation 0x0317023b __CFRunLoopDoSources0 + 235
31 CoreFoundation 0x0318d30e __CFRunLoopRun + 910
32 CoreFoundation 0x0318cb33 CFRunLoopRunSpecific + 467
33 CoreFoundation 0x0318c94b CFRunLoopRunInMode + 123
34 GraphicsServices 0x03c6a9d7 GSEventRunModal + 192
35 GraphicsServices 0x03c6a7fe GSEventRun + 104
36 UIKit 0x006c994b UIApplicationMain + 1225
37 MemberCatalog 0x000033e6 main + 134
38 libdyld.dylib 0x0395a725 start + 0
please remove this line:
self.collectionLayout.headerReferenceSize = CGSizeMake(0, 50);
then, it should works