issue with UISplitViewController in iOS 8.1: [UISplitViewController navigationBar]: unrecognized selector sent to instance - objective-c

Im trying to create a New UISPlitViewController and display it instead of current ViewController, but for some reason it's not working, it says:
-[UISplitViewController navigationBar]: unrecognized selector sent to instance
this is the code
- (IBAction)openDocuments:(id)sender {
UINavigationController *leftNavController;
UINavigationController *rightNavController;
MenuDocumentsVC *masterVC = [self.storyboard instantiateViewControllerWithIdentifier:#"MenuDocumentsVC"];
masterVC.title = #" ";
ContentDocumentsVC *detailVC = [self.storyboard instantiateViewControllerWithIdentifier:#"ContentDocumentsVC"];
detailVC.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:LOGO_COMPANY]];
masterVC.delegate = detailVC;
leftNavController = [[UINavigationController alloc] initWithRootViewController:masterVC];
rightNavController = [[UINavigationController alloc] initWithRootViewController:detailVC];
leftNavController.toolbarHidden = FALSE;
rightNavController.toolbarHidden = FALSE;
leftNavController.navigationBar.translucent = FALSE;
rightNavController.navigationBar.translucent = FALSE;
leftNavController.toolbar.translucent = FALSE;
rightNavController.toolbar.translucent = FALSE;
UISplitViewController *splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = [NSArray arrayWithObjects:leftNavController, rightNavController, nil];
splitViewController.delegate = (id)detailVC;
if ([splitViewController respondsToSelector:#selector(setPresentsWithGesture:)]) {
[splitViewController setPresentsWithGesture:NO];
}
splitViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[UIView transitionWithView:self.view.window
duration:0.5
options:UIViewAnimationOptionCurveEaseOut
animations:^{
self.view.window.rootViewController = splitViewController;
} completion:^(BOOL finished) {
}];
}
how to make it work properly??
Exception
2015-01-05 11:01:47.402 myapp[3454:607] -[UISplitViewController navigationBar]: unrecognized selector sent to instance 0x7b961f00
2015-01-05 11:01:47.406 myapp[3454:607] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UISplitViewController navigationBar]: unrecognized selector sent to instance 0x7b961f00'
*** First throw call stack:
(
0 CoreFoundation 0x010a21e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00a718e5 objc_exception_throw + 44
2 CoreFoundation 0x0113f243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0109250b ___forwarding___ + 1019
4 CoreFoundation 0x010920ee _CF_forwarding_prep_0 + 14
5 eOpenRoad 0x00056d7d +[Functions setNavigationBarControllerToHexColor:] + 333
6 eOpenRoad 0x0004fa15 -[ContentDocumentsVC viewWillAppear:] + 69
7 UIKit 0x0163e04b -[UIViewController _setViewAppearState:isAnimating:] + 448
8 UIKit 0x0163e548 -[UIViewController __viewWillAppear:] + 114
9 UIKit 0x01660c25 -[UINavigationController _startTransition:fromViewController:toViewController:] + 800
10 UIKit 0x016618cc -[UINavigationController _startDeferredTransitionIfNeeded:] + 645
11 UIKit 0x016624e9 -[UINavigationController __viewWillLayoutSubviews] + 57
12 UIKit 0x017a30d1 -[UILayoutContainerView layoutSubviews] + 213
13 UIKit 0x0158a964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
14 libobjc.A.dylib 0x00a8382b -[NSObject performSelector:withObject:] + 70
15 QuartzCore 0x001ea45a -[CALayer layoutSublayers] + 148
16 QuartzCore 0x001de244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
17 QuartzCore 0x001ea3a5 -[CALayer layoutIfNeeded] + 160
18 UIKit 0x0164cae3 -[UIViewController window:setupWithInterfaceOrientation:] + 304
19 UIKit 0x01562aa7 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
20 UIKit 0x01561646 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
21 UIKit 0x01561518 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
22 UIKit 0x015615a0 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
23 UIKit 0x0156063a __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
24 UIKit 0x0156059c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
25 UIKit 0x015612f3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
26 UIKit 0x015648e6 -[UIWindow setDelegate:] + 449
27 UIKit 0x0163eb77 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
28 UIKit 0x0155a474 -[UIWindow addRootViewControllerViewIfPossible] + 591
29 UIKit 0x0155ac84 -[UIWindow setRootViewController:] + 960
30 eOpenRoad 0x0005c5ec +[Functions openContentInWindowWithParameters:insideOfNavigationController:] + 7804
31 eOpenRoad 0x0001f42b -[ViewController openDocuments:] + 555
32 libobjc.A.dylib 0x00a83880 -[NSObject performSelector:withObject:withObject:] + 77
33 UIKit 0x0151d3b9 -[UIApplication sendAction:to:from:forEvent:] + 108
34 UIKit 0x0151d345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
35 UIKit 0x0161ebd1 -[UIControl sendAction:to:forEvent:] + 66
36 UIKit 0x0161efc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
37 UIKit 0x0161e243 -[UIControl touchesEnded:withEvent:] + 641
38 UIKit 0x0155cddd -[UIWindow _sendTouchesForEvent:] + 852
39 UIKit 0x0155d9d1 -[UIWindow sendEvent:] + 1117
40 UIKit 0x0152f5f2 -[UIApplication sendEvent:] + 242
41 UIKit 0x01519353 _UIApplicationHandleEventQueue + 11455
42 CoreFoundation 0x0102b77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
43 CoreFoundation 0x0102b10b __CFRunLoopDoSources0 + 235
44 CoreFoundation 0x010481ae __CFRunLoopRun + 910
45 CoreFoundation 0x010479d3 CFRunLoopRunSpecific + 467
46 CoreFoundation 0x010477eb CFRunLoopRunInMode + 123
47 GraphicsServices 0x03ae75ee GSEventRunModal + 192
48 GraphicsServices 0x03ae742b GSEventRun + 104
49 UIKit 0x0151bf9b UIApplicationMain + 1225
50 eOpenRoad 0x00051e3d main + 141
51 libdyld.dylib 0x036b76d9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

From provided log I can say that problem lie in [ContentDocumentsVC viewWillAppear:] where you set color to navigation bar with category method setNavigationBarControllerToHexColor: but looks like you call this method on wrong controller.

Related

Application Crash on ios11 & Xcode 9: while adding [self addChildViewController:]

While adding child viewcontroller, I am getting following crash,
Here NavigationViewController is extended from UIViewController.
This error is coming when I upgraded to Xcode 9, working successfully on earlier versions of Xcode.
I referred the Link but not getting any satisfied answer, please help me out this,
Thanx in advance. :)
The block of code is:
_mainSectionsController = [[[MainSectionsController alloc] initWithNibName:nil bundle:nil] autorelease];
[self addChildViewController:_mainSectionsController];
**Init method of _mainSectionsController** .
-(id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (!self) return nil;
self.edgesForExtendedLayout = UIRectEdgeAll;
self.viewControllers = #
[
[[[NavigationViewController alloc] initWithNibName:nil bundle:nil]
autorelease]
];
return self;
}
**init method of NavigationViewController**
-(id)initWithNibName:(NSString*)nibNameOrNil bundle: (NSBundle*)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (!self) return nil;
self.edgesForExtendedLayout = UIRectEdgeAll;
_navController = [[[UINavigationController alloc] initWithNibName:nil bundle:nil] autorelease];
_navController.get().delegate = self;
_navController.get().navigationBarHidden = YES;
_navController.get().view.clipsToBounds = YES;
_navController.get().view.backgroundColor = [UIColor clearColor];
return self;
}
2018-05-22 10:46:23.112290+0530 [912:19925] -[NavigationViewController _viewControllerSubtreeDidGainViewController:]: unrecognized selector sent to instance 0x7f91ba83c000
2018-05-22 10:46:24.939903+0530 [912:19925] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NavigationViewController _viewControllerSubtreeDidGainViewController:]: unrecognized selector sent to instance 0x7f91ba83c000'
* First throw call stack:
(
0 CoreFoundation 0x000000010f03f12b exceptionPreprocess + 171 .
1 libobjc.A.dylib 0x000000010e640f41 objc_exception_throw + 48
2 CoreFoundation 0x000000010f0c0024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 UIKit 0x000000010b2cdf51 -[UIResponder doesNotRecognizeSelector:] + 295
4 CoreFoundation 0x000000010efc1f78 ___forwarding_ + 1432
5 CoreFoundation 0x000000010efc1958 _CF_forwarding_prep_0 + 120
6 UIKit 0x000000010b246c1d -[UIViewController _addChildViewController:performHierarchyCheck:notifyWillMove:] + 696
7 UIKit 0x000000010b26930e -[UIViewController(UIContainerViewControllerProtectedMethods) addChildViewController:] + 83
8 0x00000001058eeac3 -[MainViewController initWithNibName:bundle:] + 5235
9 0x00000001059876ca -[AppDelegate loadMainViewController] + 122
10 0x0000000105984561 -[AppDelegate application:didFinishLaunchingWithOptions:] + 1137
11 UIKit 0x000000010b091bca -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 299
12 UIKit 0x000000010b093648 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4113
13 UIKit 0x000000010b098aeb -[UIApplication _runWithMainScene:transitionContext:completion:] + 1720
14 UIKit 0x000000010b4626f8 111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 924
15 UIKit 0x000000010b8384c8 +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153
16 UIKit 0x000000010b4622f1 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 249
17 UIKit 0x000000010b462b6b -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 696
18 UIKit 0x000000010bde0a69 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 262
19 UIKit 0x000000010bde0922 -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 444
20 UIKit 0x000000010babd9c8 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 221
21 UIKit 0x000000010bcbcb06 _performActionsWithDelayForTransitionContext + 100
22 UIKit 0x000000010babd88b -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 231
23 UIKit 0x000000010b837b25 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392
24 UIKit 0x000000010b09736a -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 523
25 UIKit 0x000000010b672605 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 369
26 FrontBoardServices 0x0000000116cb8cc0 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 338
27 FrontBoardServices 0x0000000116cc17b5 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 235
28 libdispatch.dylib 0x000000010f87b33d _dispatch_client_callout + 8
29 libdispatch.dylib 0x000000010f8809f3 _dispatch_block_invoke_direct + 592
30 FrontBoardServices 0x0000000116ced498 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 24
31 FrontBoardServices 0x0000000116ced14e -[FBSSerialQueue _performNext] + 464
32 FrontBoardServices 0x0000000116ced6bd -[FBSSerialQueue _performNextFromRunLoopSource] + 45
33 CoreFoundation 0x000000010efe2101 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
34 CoreFoundation 0x000000010f081f71 __CFRunLoopDoSource0 + 81
35 CoreFoundation 0x000000010efc6a19 __CFRunLoopDoSources0 + 185
36 CoreFoundation 0x000000010efc5fff __CFRunLoopRun + 1279
37 CoreFoundation 0x000000010efc5889 CFRunLoopRunSpecific + 409
38 GraphicsServices 0x000000010fed99c6 GSEventRunModal + 62
39 UIKit 0x000000010b09a5d6 UIApplicationMain + 159
40 0x000000010590c331 main + 65
41 libdyld.dylib 0x000000010f8f7d81 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Since you have autorelease in your MainSectionsController code I assume that you don't use ARC there. I highly recommend upgrading the code of MainSectionsController and NavigationViewController to ARC. This prevents accidental overreleases that might cause issues like this one.
In addition I'd recommend to move self.viewControllers assignment from the constructor to viewDidLoad if possible.

Call to UIWebView crashing my app in iOS

I have a WebView in my storyboard. I created an outlet property to that webview in my view controller file. Then in my code in I'm calling it like this:
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"news1" ofType:#"html" inDirectory:#"/HTML"]];
[self.webView loadRequest:[NSURLRequest requestWithURL:url]];
}
The problem is my app is crashing when I run this and I don't really know why. I get this error, but I need help deciphering what the issue is.
2014-05-20 20:18:10.214 MyApp[1789:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
*** First throw call stack:
(
0 CoreFoundation 0x01f7b1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x019fe8e5 objc_exception_throw + 44
2 CoreFoundation 0x01f7afbb +[NSException raise:format:] + 139
3 Foundation 0x0161a92b -[NSURL(NSURL) initFileURLWithPath:] + 123
4 Foundation 0x0161a7fd +[NSURL(NSURL) fileURLWithPath:] + 67
5 MyApp 0x00011c3d -[LVGTutorialVC viewDidLoad] + 205
6 UIKit 0x007dd33d -[UIViewController loadViewIfRequired] + 696
7 UIKit 0x00803345 -[UINavigationController _layoutViewController:] + 39
8 UIKit 0x0080385b -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 235
9 UIKit 0x00803953 -[UINavigationController _startTransition:fromViewController:toViewController:] + 78
10 UIKit 0x008048cc -[UINavigationController _startDeferredTransitionIfNeeded:] + 645
11 UIKit 0x008054e9 -[UINavigationController __viewWillLayoutSubviews] + 57
12 UIKit 0x009460d1 -[UILayoutContainerView layoutSubviews] + 213
13 UIKit 0x0072d964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
14 libobjc.A.dylib 0x01a1082b -[NSObject performSelector:withObject:] + 70
15 QuartzCore 0x01de245a -[CALayer layoutSublayers] + 148
16 QuartzCore 0x01dd6244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
17 QuartzCore 0x01dd60b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
18 QuartzCore 0x01d3c7fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
19 QuartzCore 0x01d3db85 _ZN2CA11Transaction6commitEv + 393
20 QuartzCore 0x01d3e258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
21 CoreFoundation 0x01f4336e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
22 CoreFoundation 0x01f432bf __CFRunLoopDoObservers + 399
23 CoreFoundation 0x01f21254 __CFRunLoopRun + 1076
24 CoreFoundation 0x01f209d3 CFRunLoopRunSpecific + 467
25 CoreFoundation 0x01f207eb CFRunLoopRunInMode + 123
26 GraphicsServices 0x03eab5ee GSEventRunModal + 192
27 GraphicsServices 0x03eab42b GSEventRun + 104
28 UIKit 0x006bef9b UIApplicationMain + 1225
29 MyApp 0x0002158d main + 141
30 libdyld.dylib 0x0262c701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
The HTML file isn't in your bundle or isn't at the path specified. Check the case of the file and folder name. If you build/run in the simulator, you can look through the bundle inside of ~/Library/Application Support/iPhone Simulator/7.1/Applications.
Don't use loadRequest if you want to load html locally. use this
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:#"sample" ofType:#"html"];
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
[webView loadHTMLString:htmlString baseURL:nil];

UIImagePickerController source type photo library crash in Ipad iOS7

I try to present a UIImagePickerController from rect using this code:
UIImagePickerController* imgPickerController = [[UIImagePickerController alloc] init];
imgPickerController.delegate = self;
imgPickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imgPickerController.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeImage, nil];
imgPickerController.allowsEditing = NO;
_popover = [[UIPopoverController alloc] initWithContentViewController:imgPickerController];
[_popover setDelegate:self];
[_popover presentPopoverFromRect:CGRectMake(195, 55, 70, 64) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:NO];
But sometimes crash happends... NO always, sometimes run, sometimes crash...
This is the crash LOG:
Thread 0: Crashed: com.apple.main-thread
0 CoreText 0x2e4c0d1e TComponentFont::GetRawBoundingBox() const + 13
1 CoreText 0x2e4b3ba7 TBaseFont::CalculateFontMetrics(bool) const + 110
2 CoreText 0x2e4b3ba7 TBaseFont::CalculateFontMetrics(bool) const + 110
3 CoreText 0x2e4c0d0b TComponentFont::CalculateFontMetrics(bool) const + 34
4 CoreText 0x2e4b39fd TBaseFont::InitFontMetrics() const + 44
5 CoreText 0x2e4b3839 TBaseFont::GetStrikeMetrics(float, CGAffineTransform const*, bool) const + 104
6 CoreText 0x2e4b3603 TFont::InitStrikeMetrics() const + 38
7 CoreText 0x2e4b35b9 CTFontGetAscent + 92
8 GraphicsServices 0x32a17245 GSFontEnsureExtraData + 228
9 GraphicsServices 0x32a19361 GSFontGetLatin1LayoutInfo + 44
10 UIFoundation 0x359a252d -[UIFont(UIFont_AttributedStringDrawing) _getLatin1GlyphMapping:andAdvanceMapping:] + 12
11 UIFoundation 0x35978e61 __NSStringDrawingEngine + 3784
12 UIFoundation 0x3597df7f -[NSAttributedString(NSExtendedStringDrawing) boundingRectWithSize:options:context:] + 898
13 UIKit 0x3085dcab -[UILabel _updateScaledMetricsForRect:] + 594
14 UIKit 0x306023d3 -[UILabel setAdjustsFontSizeToFitWidth:] + 206
15 PhotosUI 0x3466608b -[PUFlatWhiteInterfaceTheme configureAlbumListSubtitleLabel:]
16 PhotosUI 0x345bc141 +[PUAlbumListCellContentView _updateLabelGlobalCachedSizes]
17 libobjc.A.dylib 0x38588231 _class_initialize + 572
18 libobjc.A.dylib 0x3858f7a7 lookUpImpOrForward + 130
19 libobjc.A.dylib 0x38587feb _class_lookupMethodAndLoadCache3 + 34
20 libobjc.A.dylib 0x38587db9 _objc_msgSend_uncached + 24
21 PhotosUI 0x345bb059 -[PUAlbumListTableViewController tableView:cellForRowAtIndexPath:]
22 UIKit 0x3069aa5b -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 410
23 UIKit 0x30642e7d -[UITableView _updateVisibleCellsNow:] + 1804
24 UIKit 0x30642699 -[UITableView layoutSubviews] + 184
25 UIKit 0x30568da3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 346
26 QuartzCore 0x301efc6b -[CALayer layoutSublayers] + 142
27 QuartzCore 0x301eb47b CA::Layer::layout_if_needed(CA::Transaction*) + 350
28 UIKit 0x3057dc1b -[UIView(Hierarchy) layoutBelowIfNeeded] + 530
29 PhotosUI 0x3467ec55 -[PUAbstractAlbumListViewController viewDidLayoutSubviews]
30 UIKit 0x30568e79 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 560
31 QuartzCore 0x301efc6b -[CALayer layoutSublayers] + 142
32 QuartzCore 0x301eb47b CA::Layer::layout_if_needed(CA::Transaction*) + 350
33 QuartzCore 0x301eb30d CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
34 QuartzCore 0x301ead1f CA::Context::commit_transaction(CA::Transaction*) + 230
35 QuartzCore 0x301eab2f CA::Transaction::commit() + 314
36 UIKit 0x305610c3 _afterCACommitHandler + 126
37 CoreFoundation 0x2ddc11cd __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
38 CoreFoundation 0x2ddbeb71 __CFRunLoopDoObservers + 284
39 CoreFoundation 0x2ddbeeb3 __CFRunLoopRun + 730
40 CoreFoundation 0x2dd29c27 CFRunLoopRunSpecific + 522
41 CoreFoundation 0x2dd29a0b CFRunLoopRunInMode + 106
42 GraphicsServices 0x32a1d283 GSEventRunModal + 138
43 UIKit 0x305cd049 UIApplicationMain + 1136
44 Puzz! 0x00032665 main (main.m:16)
Thanks!
EDIT
Finally, I decided use a AssetsLibrary framework to create a custom UIImagePickerController using this MyImagePicker sample:
https://developer.apple.com/library/ios/samplecode/myimagepicker/Introduction/Intro.html

Crashing with custom navigation controller

I ran into an issue when testing my application in iOS7. The application currently runs just fine in iOS5 and iOS6. Based on the stack trace, it would appear that a private method is causing the issue.
2013-11-21 17:00:56.565 MyApp[706:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An override of -[UINavigationController navigationBar] is returning an object that is not a kind of UINavigationBar'
*** First throw call stack:
(
0 CoreFoundation 0x0244d5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01eee8b6 objc_exception_throw + 44
2 CoreFoundation 0x0244d3bb +[NSException raise:format:] + 139
3 UIKit 0x00af796c -[UINavigationController _confirmBarAccessMethods] + 277
4 UIKit 0x00af7b19 -[UINavigationController initWithNibName:bundle:] + 271
5 MyApp 0x000b8bd8 -[CustomUINavigationController initWithNibName:bundle:] + 152
6 UIKit 0x00af77b3 -[UINavigationController initWithRootViewController:] + 86
7 MyApp 0x000b8ea1 -[CustomUINavigationController initWithRootViewController:] + 113
8 MyApp 0x0000260a -[AppDelegate application:didFinishLaunchingWithOptions:] + 666
9 UIKit 0x009c7355 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
10 UIKit 0x009c7b95 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
11 UIKit 0x009cc3a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
12 UIKit 0x009e087c -[UIApplication handleEvent:withNewEvent:] + 3447
13 UIKit 0x009e0de9 -[UIApplication sendEvent:] + 85
14 UIKit 0x009ce025 _UIApplicationHandleEvent + 736
15 GraphicsServices 0x0478b2f6 _PurpleEventCallback + 776
16 GraphicsServices 0x0478ae01 PurpleEventCallback + 46
17 CoreFoundation 0x023c8d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
18 CoreFoundation 0x023c8a9b __CFRunLoopDoSource1 + 523
19 CoreFoundation 0x023f377c __CFRunLoopRun + 2156
20 CoreFoundation 0x023f2ac3 CFRunLoopRunSpecific + 467
21 CoreFoundation 0x023f28db CFRunLoopRunInMode + 123
22 UIKit 0x009cbadd -[UIApplication _run] + 840
23 UIKit 0x009cdd3b UIApplicationMain + 1225
24 MyApp 0x00002337 main + 295
25 MyApp 0x00002205 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
This crash happens only when testing in iOS7. It happens as soon as [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil] is called. I cannot find any information about _confirmBarAccessMethods. I assume it is a private UINavigationController method.
Here is the header file for the CustomUINavigationController class:
#import <UIKit/UIKit.h>
#import "CustomUINavigationBar.h"
#interface CustomUINavigationController : UINavigationController
{
CustomUINavigationBar *customNavigationBar;
}
#property (nonatomic, retain) UIColor *titleColor;
#end
This is the init method in which the application crashes:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; // This line causes the application to crash
if (self) {
customNavigationBar = [[CustomUINavigationBar alloc] init];
[customNavigationBar setTintColor:[UIColor colorWithWhite:0.0 alpha:1.0]];
[customNavigationBar setItems:[NSArray array] animated:NO];
[customNavigationBar setDelegate:self];
self.titleColor = [UIColor colorWithWhite:1.0 alpha:1.0];
}
return self;
}
Here is the header file for CustomNavigationBar:
#import <UIKit/UIKit.h>
#interface CustomUINavigationBar : UINavigationBar
{
UIImage *background;
}
#end
Any help would be greatly appreciated. I can provide more information if necessary.
EDIT: Added trace from suggested solution of using custom navigation bar initializer
2013-11-22 13:04:49.756 MyApp[390:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An override of -[UINavigationController navigationBar] is returning an object that is not a kind of UINavigationBar'
*** First throw call stack:
(
0 CoreFoundation 0x0244d5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01eee8b6 objc_exception_throw + 44
2 CoreFoundation 0x0244d3bb +[NSException raise:format:] + 139
3 UIKit 0x00af796c -[UINavigationController _confirmBarAccessMethods] + 277
4 UIKit 0x00af7b19 -[UINavigationController initWithNibName:bundle:] + 271
5 MyApp 0x000b8e38 -[CustomUINavigationController initWithNibName:bundle:] + 152
6 UIKit 0x00af7815 -[UINavigationController initWithNavigationBarClass:toolbarClass:] + 52
7 MyApp 0x00002868 -[AppDelegate application:didFinishLaunchingWithOptions:] + 712
8 UIKit 0x009c7355 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
9 UIKit 0x009c7b95 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
10 UIKit 0x009cc3a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
11 UIKit 0x009e087c -[UIApplication handleEvent:withNewEvent:] + 3447
12 UIKit 0x009e0de9 -[UIApplication sendEvent:] + 85
13 UIKit 0x009ce025 _UIApplicationHandleEvent + 736
14 GraphicsServices 0x0478b2f6 _PurpleEventCallback + 776
15 GraphicsServices 0x0478ae01 PurpleEventCallback + 46
16 CoreFoundation 0x023c8d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
17 CoreFoundation 0x023c8a9b __CFRunLoopDoSource1 + 523
18 CoreFoundation 0x023f377c __CFRunLoopRun + 2156
19 CoreFoundation 0x023f2ac3 CFRunLoopRunSpecific + 467
20 CoreFoundation 0x023f28db CFRunLoopRunInMode + 123
21 UIKit 0x009cbadd -[UIApplication _run] + 840
22 UIKit 0x009cdd3b UIApplicationMain + 1225
23 MyApp 0x00002567 main + 295
24 MyApp 0x00002435 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Create the navigation controller with initWithNavigationBarClass:toolbarClass: and supply your custom navigation bar class. Then perform any configuration you require on the instance created for you by the nav controller superclass.
I finally resolved the issue. CustomerUINavigationController had an override method for the navigationBar accessor. It was attempting to return a nil value. I removed this and the application compiled and ran with no issues.

Crash on second view transition

if (! self.mainPage)
{ self.mainPage= [[MainGameDisplay alloc] initWithNibName:nil bundle:nil]; }
[self presentViewController: self.mainPage animated:YES completion:NULL];
[self.view addSubview:self.mainPage.view];
self.mainPage.view.frame = CGRectMake(568, 0, 568, 320);//(N = horizontal, N = vertical)
[UIView animateWithDuration:1.0f
animations:^{
//actual frame needed with an animation.
self.mainPage.view.frame = CGRectMake(0, 0, 568, 320);
}
completion:^(BOOL finished) {
//ENTER HERE ANYTHING TO RUN AFTER ANIMATION IS COMPLETED:
[self presentViewController: self.mainPage animated:NO completion:NULL];
//This will make the next page load correctly after the transition, otherwise you cannot. interact with anything.
}];
#property (strong) MainGameDisplay *mainPage;
is declared in the .h file.
This code works perfectly but only once, If I was to transition to the mainPage view, come back and transition there again, it would crash at the end of the transition. I've played around so much to fix this but it just doesn't work.
=================
Stack Trace for MainGameDisplay viewDidLoad:
//First transition, A-Okay.
2012-11-11 12:27:07.547 Test_Game [584:c07] (
0 Test_Game 0x00002dab -[MainGameDisplay viewDidLoad] + 91
1 UIKit 0x000f8817 -[UIViewController loadViewIfRequired] + 536
2 UIKit 0x000f8882 -[UIViewController view] + 33
3 Test_Game 0x0000240e -[ViewController StartGame:] + 334
4 libobjc.A.dylib 0x010e3705 -[NSObject performSelector:withObject:withObject:] + 77
5 UIKit 0x0001a920 -[UIApplication sendAction:to:from:forEvent:] + 96
6 UIKit 0x0001a8b8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
7 UIKit 0x000db671 -[UIControl sendAction:to:forEvent:] + 66
8 UIKit 0x000dbbcf -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
9 UIKit 0x000dad38 -[UIControl touchesEnded:withEvent:] + 546
10 UIKit 0x0004a33f -[UIWindow _sendTouchesForEvent:] + 846
11 UIKit 0x0004a552 -[UIWindow sendEvent:] + 273
12 UIKit 0x000283aa -[UIApplication sendEvent:] + 436
13 UIKit 0x00019cf8 _UIApplicationHandleEvent + 9874
14 GraphicsServices 0x01beddf9 _PurpleEventCallback + 339
15 GraphicsServices 0x01bedad0 PurpleEventCallback + 46
16 CoreFoundation 0x01c07bf5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
17 CoreFoundation 0x01c07962 __CFRunLoopDoSource1 + 146
18 CoreFoundation 0x01c38bb6 __CFRunLoopRun + 2118
19 CoreFoundation 0x01c37f44 CFRunLoopRunSpecific + 276
20 CoreFoundation 0x01c37e1b CFRunLoopRunInMode + 123
21 GraphicsServices 0x01bec7e3 GSEventRunModal + 88
22 GraphicsServices 0x01bec668 GSEventRun + 104
23 UIKit 0x0001765c UIApplicationMain + 1211
24 Test_Game 0x00001cfd main + 141
25 Test_Game 0x00001c25 start + 53
)
//Second transition, crashes now.
2012-11-11 12:27:11.223 Test_Game [584:c07] (
0 Test_Game 0x00002dab -[MainGameDisplay viewDidLoad] + 91
1 UIKit 0x000f8817 -[UIViewController loadViewIfRequired] + 536
2 UIKit 0x000f8882 -[UIViewController view] + 33
3 Test_Game 0x0000240e -[ViewController StartGame:] + 334
4 libobjc.A.dylib 0x010e3705 -[NSObject performSelector:withObject:withObject:] + 77
5 UIKit 0x0001a920 -[UIApplication sendAction:to:from:forEvent:] + 96
6 UIKit 0x0001a8b8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
7 UIKit 0x000db671 -[UIControl sendAction:to:forEvent:] + 66
8 UIKit 0x000dbbcf -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
9 UIKit 0x000dad38 -[UIControl touchesEnded:withEvent:] + 546
10 UIKit 0x0004a33f -[UIWindow _sendTouchesForEvent:] + 846
11 UIKit 0x0004a552 -[UIWindow sendEvent:] + 273
12 UIKit 0x000283aa -[UIApplication sendEvent:] + 436
13 UIKit 0x00019cf8 _UIApplicationHandleEvent + 9874
14 GraphicsServices 0x01beddf9 _PurpleEventCallback + 339
15 GraphicsServices 0x01bedad0 PurpleEventCallback + 46
16 CoreFoundation 0x01c07bf5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
17 CoreFoundation 0x01c07962 __CFRunLoopDoSource1 + 146
18 CoreFoundation 0x01c38bb6 __CFRunLoopRun + 2118
19 CoreFoundation 0x01c37f44 CFRunLoopRunSpecific + 276
20 CoreFoundation 0x01c37e1b CFRunLoopRunInMode + 123
21 GraphicsServices 0x01bec7e3 GSEventRunModal + 88
22 GraphicsServices 0x01bec668 GSEventRun + 104
23 UIKit 0x0001765c UIApplicationMain + 1211
24 Test_Game 0x00001cfd main + 141
25 Test_Game 0x00001c25 start + 53
)
maybe you release you property in viewDidDisapear or something like this ?
what type of crash - BAD_ACCESS ?