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
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 make an UIAleartView show information when first init:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#""
message:#"..."
delegate:self
cancelButtonTitle:#"..."
otherButtonTitles:#"...", nil];
alertView.tag = 1;
[alertView show];
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (alertView.tag) {
case 1: {
[UICKeyChainStore setString:#"YES" forKey:kDebutFirstMsgShow];
if (buttonIndex == 0) {
NSNotificationCenter *noti = [NSNotificationCenter defaultCenter];
[noti postNotificationName:#"...." object:nil];
}
break;
}
default:
break;
}
}
And here is log:
2017-02-10 01:16:44.206 audition[1740:55532] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
0 CoreFoundation 0x000000010b09bd4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010aad421e objc_exception_throw + 48
2 CoreFoundation 0x000000010afcd2eb -[__NSArrayM objectAtIndex:] + 203
3 UIKit 0x0000000109854e8f __86-[_UIAlertControllerView _unlocalizedOrderedPresentableAlertActionViewRepresentations]_block_invoke + 68
4 CoreFoundation 0x000000010b02b0b2 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 114
5 CoreFoundation 0x000000010b02af42 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 194
6 UIKit 0x0000000109854dfc -[_UIAlertControllerView _unlocalizedOrderedPresentableAlertActionViewRepresentations] + 213
7 UIKit 0x00000001098543b5 -[_UIAlertControllerView _reloadInterfaceActionViewRepresentations] + 50
8 UIKit 0x0000000109855f6e -[_UIAlertControllerView _setVisualStyle:] + 380
9 UIKit 0x00000001090bab35 -[UIAlertController _updateProvidedStyleWithTraitCollection:] + 455
10 UIKit 0x00000001090bac0f -[UIAlertController _updateProvidedStyle] + 57
11 UIKit 0x00000001090bae7a -[UIAlertController traitCollectionDidChange:] + 236
12 UIKit 0x0000000108eedfac -[UIViewController _traitCollectionDidChange:] + 108
13 UIKit 0x0000000108eee0cf -[UIViewController _updateTraitsIfNecessary] + 269
14 UIKit 0x0000000108e12957 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 884
15 QuartzCore 0x000000010bb2abf8 -[CALayer layoutSublayers] + 146
16 QuartzCore 0x000000010bb1e440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
17 UIKit 0x0000000108e00928 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1509
18 UIKit 0x0000000108df6e33 -[UIView(Geometry) setBounds:] + 2387
19 UIKit 0x0000000108df603d -[UIView(Geometry) _applyISEngineLayoutValuesToBoundsOnly:] + 608
20 UIKit 0x0000000108e0080e -[UIView(Hierarchy) layoutBelowIfNeeded] + 1227
21 UIKit 0x0000000108df315b -[UIView(Geometry) setFrame:] + 1297
22 UIKit 0x00000001090b9f26 -[UIAlertController loadView] + 201
23 UIKit 0x0000000108eef61c -[UIViewController loadViewIfRequired] + 201
24 UIKit 0x0000000108eefe70 -[UIViewController view] + 27
25 UIKit 0x0000000108f0a0a5 -[UIViewController _setPresentationController:] + 100
26 UIKit 0x0000000108f015f4 -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1355
27 UIKit 0x0000000108f0328e -[UIViewController _presentViewController:withAnimationController:completion:] + 4971
28 UIKit 0x0000000108f0626b -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 530
29 UIKit 0x0000000108f05d51 -[UIViewController presentViewController:animated:completion:] + 179
30 UIKit 0x00000001098413bf -[_UIAlertControllerShimPresenterWindow presentAlertController:animated:completionBlock:] + 642
31 UIKit 0x000000010983f6f6 -[_UIAlertControllerShimPresenter _presentAlertControllerAnimated:completion:] + 219
32 UIKit 0x00000001090d42e6 -[UIAlertView _showAnimated:] + 278
33 audition 0x00000001063f9840 -[DebutVC viewWillAppear:] + 448
34 UIKit 0x0000000108ef596f -[UIViewController _setViewAppearState:isAnimating:] + 692
35 UIKit 0x0000000108ef607f -[UIViewController __viewWillAppear:] + 147
36 UIKit 0x0000000108e0b59b __86+[UIView(Internal) _transitionFromView:toView:duration:options:animations:completion:]_block_invoke + 62
37 UIKit 0x0000000108e085c0 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 581
38 UIKit 0x0000000108e087f2 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:animations:start:completion:] + 145
39 UIKit 0x0000000108e0b4bf +[UIView(Internal) _transitionFromView:toView:duration:options:animations:completion:] + 603
40 UIKit 0x0000000108f1677a -[UIViewController(UIContainerViewControllerProtectedMethods) transitionFromViewController:toViewController:duration:options:animations:completion:] + 771
41 audition 0x000000010645c1b1 -[MHTabBarController setSelectedIndex:animated:] + 2849
42 audition 0x000000010645cca3 -[MHTabBarController tabButtonPressed:] + 99
43 UIKit 0x0000000108d4f8bc -[UIApplication sendAction:to:from:forEvent:] + 83
44 UIKit 0x0000000108ed5c38 -[UIControl sendAction:to:forEvent:] + 67
45 UIKit 0x0000000108ed5f51 -[UIControl _sendActionsForEvents:withEvent:] + 444
46 UIKit 0x0000000108ed4910 -[UIControl touchesBegan:withEvent:] + 304
47 UIKit 0x0000000108dbd285 -[UIWindow _sendTouchesForEvent:] + 2043
48 UIKit 0x0000000108dbec33 -[UIWindow sendEvent:] + 4011
49 UIKit 0x0000000108d6b9ab -[UIApplication sendEvent:] + 371
50 UIKit 0x000000010955872d __dispatchPreprocessedEventFromEventQueue + 3248
51 UIKit 0x0000000109551463 __handleEventQueue + 4879
52 CoreFoundation 0x000000010b040761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
53 CoreFoundation 0x000000010b02598c __CFRunLoopDoSources0 + 556
54 CoreFoundation 0x000000010b024e76 __CFRunLoopRun + 918
55 CoreFoundation 0x000000010b024884 CFRunLoopRunSpecific + 420
56 GraphicsServices 0x000000010ca64a6f GSEventRunModal + 161
57 UIKit 0x0000000108d4dc68 UIApplicationMain + 159
58 audition 0x0000000106493c91 main + 241
59 libdyld.dylib 0x000000010d05868d start + 1
From the log file NSRangeException there is an array empty but i access to element 0 of it. But
Crash disappear when i comment [alertview show];
What is reason of this crash ?
The crash log shows that your code is happening here:
33 audition 0x00000001063f9840 -[DebutVC viewWillAppear:] + 448
You can't show an alert from viewWillAppear, because your view is not in the interface yet (it will appear, but it has not yet done so). Try moving your show code to viewDidAppear instead.
when i run my app, i received this error :
2014-08-11 10:52:10.546 ControlViewTest[918:60b] -[UIViewController collectionView:numberOfItemsInSection:]: unrecognized selector sent to instance 0x8c862f0
2014-08-11 10:52:10.605 ControlViewTest[918:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController collectionView:numberOfItemsInSection:]: unrecognized selector sent to instance 0x8c862f0'
* First throw call stack:
(
0 CoreFoundation 0x017ec1e4 exceptionPreprocess + 180
1 libobjc.A.dylib 0x0156b8e5 objc_exception_throw + 44
2 CoreFoundation 0x01889243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x017dc50b ___forwarding_ + 1019
4 CoreFoundation 0x017dc0ee _CF_forwarding_prep_0 + 14
5 UIKit 0x008b0c34 -[UICollectionViewData _updateItemCounts] + 331
6 UIKit 0x008b0ce1 -[UICollectionViewData _validateItemCounts] + 45
7 UIKit 0x008b2c64 -[UICollectionViewData numberOfSections] + 35
8 UIKit 0x0087d6ed -[UICollectionView numberOfSections] + 62
9 UIKit 0x0089d614 -[UICollectionViewFlowLayout(Internal) _getSizingInfos] + 205
10 UIKit 0x0089e48f -[UICollectionViewFlowLayout(Internal) _fetchItemsInfo] + 521
11 UIKit 0x00899fe2 -[UICollectionViewFlowLayout prepareLayout] + 157
12 UIKit 0x008b0d9d -[UICollectionViewData _prepareToLoadData] + 76
13 UIKit 0x008b15c5 -[UICollectionViewData validateLayoutInRect:] + 56
14 UIKit 0x00877603 -[UICollectionView layoutSubviews] + 173
15 UIKit 0x0029a964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
16 libobjc.A.dylib 0x0157d82b -[NSObject performSelector:withObject:] + 70
17 QuartzCore 0x03c5745a -[CALayer layoutSublayers] + 148
18 QuartzCore 0x03c4b244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
19 QuartzCore 0x03c573a5 -[CALayer layoutIfNeeded] + 160
20 UIKit 0x0035cae3 -[UIViewController window:setupWithInterfaceOrientation:] + 304
21 UIKit 0x00272aa7 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
22 UIKit 0x00271646 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
23 UIKit 0x00271518 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
24 UIKit 0x002715a0 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
25 UIKit 0x0027063a 57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
26 UIKit 0x0027059c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
27 UIKit 0x002712f3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
28 UIKit 0x002748e6 -[UIWindow setDelegate:] + 449
29 UIKit 0x0034eb77 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
30 UIKit 0x0026a474 -[UIWindow addRootViewControllerViewIfPossible] + 591
31 UIKit 0x0026a5ef -[UIWindow _setHidden:forced:] + 312
32 UIKit 0x0026a86b -[UIWindow _orderFrontWithoutMakingKey] + 49
33 UIKit 0x002753c8 -[UIWindow makeKeyAndVisible] + 65
34 UIKit 0x00225bc0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
35 UIKit 0x0022a667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
36 UIKit 0x0023ef92 -[UIApplication handleEvent:withNewEvent:] + 3517
37 UIKit 0x0023f555 -[UIApplication sendEvent:] + 85
38 UIKit 0x0022c250 _UIApplicationHandleEvent + 683
39 GraphicsServices 0x037e1f02 _PurpleEventCallback + 776
40 GraphicsServices 0x037e1a0d PurpleEventCallback + 46
41 CoreFoundation 0x01767ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 53
42 CoreFoundation 0x017679db __CFRunLoopDoSource1 + 523
43 CoreFoundation 0x0179268c __CFRunLoopRun + 2156
44 CoreFoundation 0x017919d3 CFRunLoopRunSpecific + 467
45 CoreFoundation 0x017917eb CFRunLoopRunInMode + 123
46 UIKit 0x00229d9c -[UIApplication _run] + 840
47 UIKit 0x0022bf9b UIApplicationMain + 1225
48 ControlViewTest 0x0000264d main + 141
49 libdyld.dylib 0x01e33701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
somebody can help me pls
Your UICollectionView has a data source set which does not implement the required method collectionView:numberOfItemsInSection:. You need to assign your UICollectionView a valid data source: a class that you've written and that implements collectionView:numberOfItemsInSection:.
I am simply pushing a UITableviewController to navigation stack. Code works fine in both iOS 4.3 and 5 but crashes in iOS 6. Exception is:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "MenuController" nib but the view outlet was not set.'
I know this exception is raised when view outlet is not set. Outlet is set automatically by IB as you can see in figure, but still the same. What am I doing wrong?
Simple code pushing the controller:
MenuController *menu = [[MenuController alloc] initWithStyle:UITableViewStylePlain];
menu.title = #"Watches";
menu.MenuToBeDisplayed = #"main menu";
[self.navigationController pushViewController:menu animated:YES];
Stack trace is:
0 CoreFoundation 0x01f3e02e __exceptionPreprocess + 206
1 libobjc.A.dylib 0x01a12e7e objc_exception_throw + 44
2 CoreFoundation 0x01f3ddeb +[NSException raise:format:] + 139
3 UIKit 0x00a3af18 -[UIViewController _loadViewFromNibNamed:bundle:] + 505
4 UIKit 0x00a3b418 -[UIViewController loadView] + 302
5 UIKit 0x00b8934e -[UITableViewController loadView] + 80
6 UIKit 0x00a3b648 -[UIViewController loadViewIfRequired] + 73
7 UIKit 0x00a3b882 -[UIViewController view] + 33
8 UIKit 0x00a3bb2a -[UIViewController contentScrollView] + 36
9 UIKit 0x00a52ef5 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 36
10 UIKit 0x00a52fdb -[UINavigationController _layoutViewController:] + 43
11 UIKit 0x00a53286 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 254
12 UIKit 0x00a53381 -[UINavigationController _startTransition:fromViewController:toViewController:] + 72
13 UIKit 0x00a53eab -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
14 UIKit 0x00a544a3 -[UINavigationController pushViewController:transition:forceImmediate:] + 1030
15 UIKit 0x00a54098 -[UINavigationController pushViewController:animated:] + 62
16 Tick 0x000e5f02 -[MarketWatchViewController openMenu] + 274
17 libobjc.A.dylib 0x01a26705 -[NSObject performSelector:withObject:withObject:] + 77
18 UIKit 0x0095d920 -[UIApplication sendAction:to:from:forEvent:] + 96
19 UIKit 0x00b99b24 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
20 libobjc.A.dylib 0x01a26705 -[NSObject performSelector:withObject:withObject:] + 77
21 UIKit 0x0095d920 -[UIApplication sendAction:to:from:forEvent:] + 96
22 UIKit 0x0095d8b8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
23 UIKit 0x00a1e671 -[UIControl sendAction:to:forEvent:] + 66
24 UIKit 0x00a1ebcf -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
25 UIKit 0x00a1dd38 -[UIControl touchesEnded:withEvent:] + 546
26 UIKit 0x0098d33f -[UIWindow _sendTouchesForEvent:] + 846
27 UIKit 0x0098d552 -[UIWindow sendEvent:] + 273
28 UIKit 0x0096b3aa -[UIApplication sendEvent:] + 436
29 UIKit 0x0095ccf8 _UIApplicationHandleEvent + 9874
30 GraphicsServices 0x0291adf9 _PurpleEventCallback + 339
31 GraphicsServices 0x0291aad0 PurpleEventCallback + 46
32 CoreFoundation 0x01eb3bf5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
33 CoreFoundation 0x01eb3962 __CFRunLoopDoSource1 + 146
34 CoreFoundation 0x01ee4bb6 __CFRunLoopRun + 2118
35 CoreFoundation 0x01ee3f44 CFRunLoopRunSpecific + 276
36 CoreFoundation 0x01ee3e1b CFRunLoopRunInMode + 123
37 GraphicsServices 0x029197e3 GSEventRunModal + 88
38 GraphicsServices 0x02919668 GSEventRun + 104
39 UIKit 0x0095a65c UIApplicationMain + 1211
40 Tick 0x00002dc5 main + 197
41 Tick 0x00002cb5 start + 53
EDIT:
I have removed nib file, and also initWithNibName: method, but I am still getting this stupid exception since yesterday. This will drive me crazy :(
With
MenuController *menu = [[MenuController alloc] initWithStyle:UITableViewStylePlain];
You aren't using your xib file at all becouse for initing contreoller with xib you need to use
initWithNibName:bundle: instead of initWithStyle:
and then set your controller's class on xib like this
I am gettting the below issue in my application (Pls help me):
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [1.07157e-08 nan]'
*** Call stack at first throw:
(
0 CoreFoundation 0x3126a64f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x32b12c5d objc_exception_throw + 24
2 CoreFoundation 0x3126a491 +[NSException raise:format:arguments:] + 68
3 CoreFoundation 0x3126a4cb +[NSException raise:format:] + 34
4 QuartzCore 0x32c6f61d _ZL18CALayerSetPositionP7CALayerRKN2CA4Vec2IdEEb + 140
5 QuartzCore 0x32c6f58b -[CALayer setPosition:] + 38
6 QuartzCore 0x32c6f4d7 -[CALayer setFrame:] + 390
7 UIKit 0x35a31455 -[UIView(Geometry) setFrame:] + 188
8 UIKit 0x35a51743 UIViewCommonInitWithFrame + 594
9 UIKit 0x35a514a1 -[UIView initWithFrame:] + 84
10 CaCaCard 0x0000683b -[CaCaCardsAppViewController shouldAutorotateToInterfaceOrientation:] + 510
11 UIKit 0x35a6eead -[UIViewController _isSupportedInterfaceOrientation:] + 48
12 UIKit 0x35a6ee6f -[UINavigationController _doesTopViewControllerSupportInterfaceOrientation:] + 46
13 UIKit 0x35a6ee37 -[UINavigationController shouldAutorotateToInterfaceOrientation:] + 14
14 UIKit 0x35a6edbf -[UINavigationController _isSupportedInterfaceOrientation:] + 54
15 UIKit 0x35a6fbbb -[UIViewController window:shouldAutorotateToInterfaceOrientation:] + 46
16 UIKit 0x35a6f857 -[UIWindow _shouldAutorotateToInterfaceOrientation:] + 194
17 UIKit 0x35a6f4a3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 366
18 UIKit 0x35a6f0ad -[UIWindow setDelegate:] + 168
19 UIKit 0x35a6efa9 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 64
20 UIKit 0x35a6d611 -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 460
21 UIKit 0x35a6d3e5 -[UINavigationController viewDidMoveToWindow:shouldAppearOrDisappear:] + 36
22 UIKit 0x35a4c5a7 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 506
23 UIKit 0x35a4c32f -[UIView(Hierarchy) _postMovedFromSuperview:] + 106
24 UIKit 0x35a31c1b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 678
25 UIKit 0x35a3196b -[UIView(Hierarchy) addSubview:] + 22
26 CaCaCard 0x00004bcf -[CaCaCardsAppAppDelegate application:didFinishLaunchingWithOptions:] + 318
27 UIKit 0x35a61821 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 772
28 UIKit 0x35a5bb65 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 272
29 UIKit 0x35a307d7 -[UIApplication handleEvent:withNewEvent:] + 1114
30 UIKit 0x35a30215 -[UIApplication sendEvent:] + 44
31 UIKit 0x35a2fc53 _UIApplicationHandleEvent + 5090
32 GraphicsServices 0x31d37e77 PurpleEventCallback + 666
33 CoreFoundation 0x31241a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
34 CoreFoundation 0x3124383f __CFRunLoopDoSource1 + 166
35 CoreFoundation 0x3124460d __CFRunLoopRun + 520
36 CoreFoundation 0x311d4ec3 CFRunLoopRunSpecific + 230
37 CoreFoundation 0x311d4dcb CFRunLoopRunInMode + 58
38 UIKit 0x35a5ad49 -[UIApplication _run] + 372
39 UIKit 0x35a58807 UIApplicationMain + 670
40 CaCaCard 0x000028e7 main + 70
41 CaCaCard 0x0000289c start + 40
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.5 (8L1)/Symbols/Developer/usr/lib/libXcod
eDebuggerSupport.dylib (file not found).
(gdb)
-(void) viewWillAppear:(BOOL)animated
//-----------------------------------
{
if ( self.interfaceOrientation == UIInterfaceOrientationPortrait ||
self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown )
{
[NSThread sleepForTimeInterval:0.5];
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[[UIApplication sharedApplication] setStatusBarOrientation:
UIInterfaceOrientationLandscapeRight];
UIScreen *screen = [UIScreen mainScreen];
CGFloat screenWidth = screen.bounds.size.width;
CGFloat screenHeight = screen.bounds.size.height;
UIView *navView = [[self navigationController] view];
navView.bounds = CGRectMake(0, 0, screenHeight, screenWidth);
navView.transform = CGAffineTransformIdentity;
navView.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
navView.center = CGPointMake(screenWidth/2.0, screenHeight/2.0);
[UIView commitAnimations];
}
fontSelected = NO;
}
The problem is an invalid frame size you are setting at some point. Probably a rect with a zero value somewhere.
From your code I would suspect you are getting some unexpected values back when you are asking for the screen size.
Also don't use those old animation functions. Use the block based animation. It's much better.