Auto Layout Crashes When Adding Constraints to UITableView - ios

I am trying to add a UIView subview to a UITableView that will rotate appropriately with the device. I want the subview to cover the entire table. Here is my method, called from viewDidLoad:
-(void)welcomeScreen {
UIView *newView = [[UIView alloc] initWithFrame:self.view.frame];
newView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
newView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:newView];
NSDictionary *views = NSDictionaryOfVariableBindings(newView);
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:#"V:|[newView]|"
options:0
metrics:nil
views:views]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:#"H:|[newView]|"
options:0
metrics:nil
views:views]];
}
When I run this method in an otherwise unedited project from the Master/Detail Xcode template, I get the following errors immediately on launch:
2014-08-21 13:51:02.141 TEST AutoLayout[2318:60b] *** Assertion failure in -[UITableView layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2935.137/UIView.m:8794
2014-08-21 13:51:02.145 TEST AutoLayout[2318:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UITableView's implementation of -layoutSubviews needs to call super.'
And here is the full stack trace:
*** First throw call stack:
(
0 CoreFoundation 0x017f01e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0156f8e5 objc_exception_throw + 44
2 CoreFoundation 0x017f0048 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0114f4de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x0029ea38 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 567
5 libobjc.A.dylib 0x0158182b -[NSObject performSelector:withObject:] + 70
6 QuartzCore 0x03c5b45a -[CALayer layoutSublayers] + 148
7 QuartzCore 0x03c4f244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
8 QuartzCore 0x03c5b3a5 -[CALayer layoutIfNeeded] + 160
9 UIKit 0x00360ae3 -[UIViewController window:setupWithInterfaceOrientation:] + 304
10 UIKit 0x00276aa7 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
11 UIKit 0x00275646 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
12 UIKit 0x00275518 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
13 UIKit 0x002755a0 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
14 UIKit 0x0027463a __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
15 UIKit 0x0027459c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
16 UIKit 0x002752f3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
17 UIKit 0x002788e6 -[UIWindow setDelegate:] + 449
18 UIKit 0x00352b77 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
19 UIKit 0x0026e474 -[UIWindow addRootViewControllerViewIfPossible] + 591
20 UIKit 0x0026e5ef -[UIWindow _setHidden:forced:] + 312
21 UIKit 0x0026e86b -[UIWindow _orderFrontWithoutMakingKey] + 49
22 UIKit 0x002793c8 -[UIWindow makeKeyAndVisible] + 65
23 UIKit 0x00229bc0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
24 UIKit 0x0022e667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
25 UIKit 0x00242f92 -[UIApplication handleEvent:withNewEvent:] + 3517
26 UIKit 0x00243555 -[UIApplication sendEvent:] + 85
27 UIKit 0x00230250 _UIApplicationHandleEvent + 683
28 GraphicsServices 0x037e5f02 _PurpleEventCallback + 776
29 GraphicsServices 0x037e5a0d PurpleEventCallback + 46
30 CoreFoundation 0x0176bca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
31 CoreFoundation 0x0176b9db __CFRunLoopDoSource1 + 523
32 CoreFoundation 0x0179668c __CFRunLoopRun + 2156
33 CoreFoundation 0x017959d3 CFRunLoopRunSpecific + 467
34 CoreFoundation 0x017957eb CFRunLoopRunInMode + 123
35 UIKit 0x0022dd9c -[UIApplication _run] + 840
36 UIKit 0x0022ff9b UIApplicationMain + 1225
37 TEST AutoLayout 0x000025ed main + 141
38 libdyld.dylib 0x01e37701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I am fairly new to Auto Layout (perhaps quite obviously), so any broad explanation of my likely fundamental misunderstandings would be greatly appreciated!
Thanks!

While this doesn't directly answer your question about autoLayout, I find doing what you're looking to do in the following way is much simpler:
- (void)welcomeScreen {
UIView *newView = [[UIView alloc] initWithFrame:self.view.frame];
newView.backgroundColor = [UIColor redColor];
newView.autoresizingMask = UIViewAutoresizingFlexibleHeight + UIViewAutoresizingFlexibleWidth;
[self.view addSubview:newView];
}

Related

Cannot change UIView background colour

I have an iOS app which contains a UIView and a sub UIView in my ViewController. (Created in Storyboard).
I want to change the background colour of the subview in an IBAction but the app just crashes. Here is my code:
-(IBAction)open_popup {
[popupView setBackgroundColor:[UIColor colorWithRed:0 green:255 blue:0 alpha:1.0]];
}
Update - This is how I have declared the popup view
IBOutlet UIView *popupView; // in my header file
Update - Here is the error I am getting
2014-08-02 18:20:39.009 ZenApp[1373:60b] 4
2014-08-02 18:20:39.011 ZenApp[1373:60b] -[NSCFType CGColor]: unrecognized selector sent to instance 0x10c896a60
2014-08-02 18:20:39.015 ZenApp[1373:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType CGColor]: unrecognized selector sent to instance 0x10c896a60' *
First throw call stack: (
0 CoreFoundation 0x0000000101f05495 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000101c6499e objc_exception_throw + 43
2 CoreFoundation 0x0000000101f9665d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000101ef6d8d ___forwarding_ + 973
4 CoreFoundation 0x0000000101ef6938 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010086466c -[UIView(Hierarchy) _setBackgroundColor:] + 37
6 ZenApp 0x00000001000036f8 -[ViewController change_colour_stage_4] + 168
7 ZenApp 0x0000000100002e5d -[ViewController change_colours] + 205
8 ZenApp 0x00000001000030db -[ViewController change_colour_stage_1] + 587
9 ZenApp 0x0000000100002d17 -[ViewController viewDidLoad] + 3079
10 UIKit 0x000000010090759e -[UIViewController loadViewIfRequired] + 562
11 UIKit 0x0000000100907777 -[UIViewController view] + 29
12 UIKit 0x00000001008502d2 -[UIWindow handleStatusBarChangeFromHeight:toHeight:] + 530
13 UIKit 0x0000000100851ca6 +[UIWindow _noteStatusBarHeightChanged:oldHeight:forAutolayoutRootViewsOnly:] + 230
14 UIKit 0x000000010086a92f +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 460
15 UIKit 0x000000010086abc5 +[UIView(UIViewAnimationWithBlocks) animateWithDuration:animations:completion:] + 59
16 UIKit 0x0000000100813bf5 -[UIApplication _setStatusBarHidden:animationParameters:changeApplicationFlag:] + 478
17 UIKit 0x0000000100847c33 -[UIWindow _setHidden:forced:] + 221
18 UIKit 0x0000000100850ffa -[UIWindow makeKeyAndVisible] + 51
19 UIKit 0x000000010080cc98 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1788
20 UIKit 0x0000000100810a0c -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 660
21 UIKit 0x0000000100821d4c -[UIApplication handleEvent:withNewEvent:] + 3189
22 UIKit 0x0000000100822216 -[UIApplication sendEvent:] + 79
23 UIKit 0x0000000100812086 _UIApplicationHandleEvent + 578
24 GraphicsServices 0x000000010386671a _PurpleEventCallback + 762
25 GraphicsServices 0x00000001038661e1 PurpleEventCallback + 35
26 CoreFoundation 0x0000000101e87679 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 41
27 CoreFoundation 0x0000000101e8744e __CFRunLoopDoSource1 + 478
28 CoreFoundation 0x0000000101eb0903 __CFRunLoopRun + 1939
29 CoreFoundation 0x0000000101eafd83 CFRunLoopRunSpecific + 467
30 UIKit 0x00000001008102e1 -[UIApplication _run] + 609
31 UIKit 0x0000000100811e33 UIApplicationMain + 1010
32 ZenApp 0x0000000100004413 main + 115
33 libdyld.dylib 0x00000001034e65fd start + 1
34 ??? 0x0000000000000001 0x0 + 1 )
libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
Thanks for your time, Dan.
Your stack trace shows this:
2 CoreFoundation 0x0000000101f9665d -[NSObject(NSObject)
doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x0000000101ef6d8d
___forwarding_ + 973 4 CoreFoundation 0x0000000101ef6938 _CF_forwarding_prep_0 + 120 5 UIKit 0x000000010086466c -[UIView(Hierarchy) _setBackgroundColor:] + 37
Which means popupView has no idea what setBackgroundColor is. (doesNotRecognizeSelector)
Check and make sure that popupView is actually a valid UIView object.
Ok well I tried #Tander solution but then Xcode suggested I access the UIView like this: "->" and then it worked.... I'm not sure why though. If anyone knows, I would be grateful if you could explain why it works this way.
Old code:
[popupView setBackgroundColor:[UIColor colorWithRed:0.0f/255.0f green:255/255 blue:0/255 alpha:1.0]];
New code:
[self->popupView setBackgroundColor:[UIColor colorWithRed:0.0f/255.0f green:255/255 blue:0/255 alpha:1.0]];
This did the trick.
Even you can set the image as background as shown below:
For color
popupView.backgroundColor = [UIColor colorWithRed:0 green:255 blue:0 alpha:1.0];
For set the Image as background:
popupView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"ImageName.png"]];

MKMapView unexpected crash issue

In viewDidLoad I have only 2 strings:
MKMapView *mapViewMy = [[MKMapView alloc]init];
[self.view addSubview:mapViewMy];
And the app crashed on "[self.view addSubview:mapViewMy]". I use iOS7. It crashes both on devices and simulators. When I use simulator I have crash report:
2013-11-06 13:34:15.948 MyBex JAPanel[36286:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x0216c5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01eef8b6 objc_exception_throw + 44
2 CoreFoundation 0x0211ebcc -[__NSArrayM insertObject:atIndex:] + 844
3 CoreFoundation 0x0211e870 -[__NSArrayM addObject:] + 64
4 UIKit 0x01190b67 PushNextClassForSettingIMP + 358
5 UIKit 0x0118905e TaggingAppearanceObjectSetterIMP + 43
6 UIKit 0x00d6d8de -[UIViewController _setUpLayoutGuideConstraintIfNecessaryAtTop:] + 424
7 UIKit 0x00d6c1c3 -[UIViewController topLayoutGuide] + 140
8 MapKit 0x023d16a8 -[MKMapView updateLayoutGuides] + 82
9 MapKit 0x023d17e7 -[MKMapView didMoveToSuperview] + 68
10 UIKit 0x00cba636 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 472
11 UIKit 0x00cba388 -[UIView(Hierarchy) _postMovedFromSuperview:] + 260
12 UIKit 0x00cc54c1 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1847
13 UIKit 0x00cb89b1 -[UIView(Hierarchy) addSubview:] + 56
14 UIKit 0x01189077 TaggingAppearanceObjectSetterIMP + 68
15 MyBex JAPanel 0x0001180e -[MapViewController configureView] + 142
16 MyBex JAPanel 0x00011778 -[MapViewController viewDidLoad] + 88
17 UIKit 0x00d71318 -[UIViewController loadViewIfRequired] + 696
18 UIKit 0x00d96b15 -[UINavigationController _layoutViewController:] + 39
19 UIKit 0x00d9702b -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 235
20 UIKit 0x00d97123 -[UINavigationController _startTransition:fromViewController:toViewController:] + 78
21 UIKit 0x00d9809c -[UINavigationController _startDeferredTransitionIfNeeded:] + 645
22 UIKit 0x00d98cb9 -[UINavigationController __viewWillLayoutSubviews] + 57
23 UIKit 0x00ed2181 -[UILayoutContainerView layoutSubviews] + 213
24 UIKit 0x00cc8267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
25 libobjc.A.dylib 0x01f0181f -[NSObject performSelector:withObject:] + 70
26 QuartzCore 0x005c82ea -[CALayer layoutSublayers] + 148
27 QuartzCore 0x005bc0d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
28 QuartzCore 0x005bbf40 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
29 QuartzCore 0x00523ae6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
30 QuartzCore 0x00524e71 _ZN2CA11Transaction6commitEv + 393
31 QuartzCore 0x005e1430 +[CATransaction flush] + 52
32 UIKit 0x00c79dc9 _afterCACommitHandler + 131
33 CoreFoundation 0x021344ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
34 CoreFoundation 0x0213441f __CFRunLoopDoObservers + 399
35 CoreFoundation 0x02112344 __CFRunLoopRun + 1076
36 CoreFoundation 0x02111ac3 CFRunLoopRunSpecific + 467
37 CoreFoundation 0x021118db CFRunLoopRunInMode + 123
38 GraphicsServices 0x027f29e2 GSEventRunModal + 192
39 GraphicsServices 0x027f2809 GSEventRun + 104
40 UIKit 0x00c5dd3b UIApplicationMain + 1225
41 MyBex JAPanel 0x0003bc0d main + 141
42 libdyld.dylib 0x03423725 start + 0
43 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I checked, both mapViewMy and self.view are not nil.
Its seems like in our viewDidLoad your object is miss referencing
Make sure you have added Framework of MapKit
Import Map Kit & Delegate in your .h file
Try this code :
MKMapView *mapViewMy = [[MKMapView alloc] initWithFrame:self.view.bounds];
mapViewMy.delegate=self;
[self.view addSubview:mapViewMy];
You need to add map kit delegates methods. :)
in .h file
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
//import MKMapkit framwork
#interface mapSampleViewController : UIViewController {
<MKMapViewDelegate>//mapview delegate
{
MKMapView *mapView;
}
in .m file
add this code in viewdidload
mapView= [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
mapView.delegate = self;
[self.view addSubview:mapView];

Xcode 5 / iOS 7 setCollectionViewLayout crash

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

'NSInternalInconsistencyException' - unable to push uitableviewcontroller on uinavigationcontroller ios 6

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

Crash when installing the app on ipad, works fine in simulator

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.

Resources