Crash on second view transition - objective-c

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 ?

Related

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

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.

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

unknown app crash ahappening due to UIPopoverController

0 CoreFoundation 0x2e11ef4e __exceptionPreprocess + 126
1 libobjc.A.dylib 0x3892d6aa objc_exception_throw + 34
2 CoreFoundation 0x2e11ee90 +[NSException raise:format:] + 100
3 UIKit 0x30da0cae -[UIPopoverController _commonPresentPopoverFromRect:inView:permittedArrowDirections:animated:] + 494
4 UIKit 0x30da1ef0 -[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:] + 48
5 TestApp 0x0018a236 -[TestAppController showCheckInOutPopoverWithStatus:] (TestAppController.m:7591)
6 TestApp 0x0016ae80 -[TestAppController tableView:didSelectRowAtIndexPath:] (TestAppController.m:5499)
7 UIKit 0x309ad326 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1074
8 UIKit 0x30a6024e -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 210
9 UIKit 0x3091096c _applyBlockToCFArrayCopiedToStack + 312
10 UIKit 0x3088846e _afterCACommitHandler + 426
11 CoreFoundation 0x2e0ea1d0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 16
12 CoreFoundation 0x2e0e7b74 __CFRunLoopDoObservers + 280
13 CoreFoundation 0x2e0e7eb6 __CFRunLoopRun + 726
14 CoreFoundation 0x2e052ce2 CFRunLoopRunSpecific + 518
15 CoreFoundation 0x2e052ac6 CFRunLoopRunInMode + 102
16 GraphicsServices 0x32d4d27e GSEventRunModal + 134
17 UIKit 0x308f4a3c UIApplicationMain + 1132
uiCustomPopover = [[UIPopoverController alloc] initWithContentViewController:self.TestAppDisplayPopoverViewController];
[uiCustomPopover setPopoverContentSize:CGSizeMake(354.5, 229.5)];
uiCustomPopover.delegate=self;
[uiCustomPopover presentPopoverFromRect:CGRectMake(250,15.0, 1.0, 1.0) inView:someView permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
Above is the crash log for my app, I am not getting any idea, what could be the cause of the crash?Does it have to be because of UIPopoverController or because of PresentPopoverFromRect. Any kind of help is greatly appreciated.
Thanks in advance :)
Code added...
try to make
#property (strong, nonatomic) UIPopoverController *uiCustomPopover;
and then:
self.uiCustomPopover = [[UIPopoverController alloc] initWithContentViewController:self.TestAppDisplayPopoverViewController];
[self.uiCustomPopover setPopoverContentSize:CGSizeMake(354.5, 229.5)];
self.uiCustomPopover.delegate=self;
[self.uiCustomPopover presentPopoverFromRect:CGRectMake(250,15.0, 1.0, 1.0) inView:someView permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
That should help. I also had the same problem like UIPopoverController did deallocated before presented or something...

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.

xcode 'NSInvalidArgumentException', reason: '-[cure superview]: unrecognized selector sent to instance 0x4e3b7b0'

i am not sure why i am getting this error
i created a regular tab bar application
made 5 tabs (compiles and runs)
then put a tableview in one of the tabs , put the code below and i get this error
cure.h
#import <UIKit/UIKit.h>
#interface cure : UIViewController
<UITableViewDataSource, UITableViewDelegate>
{
NSArray *exercises;
}
#end
cure.m
#import "cure.h"
#implementation cure
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"cell"];
// create a cell
if ( cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:#"cell"];
}
// set the main text
cell.textLabel.text = [exercises objectAtIndex:indexPath.row];
// return the cell.
return cell;
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
exercises = [[NSArray alloc]
initWithObjects:#"An Interesting Title",
#"A Not That Interesting Title",
#"And Still Another Title", nil];
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
#end
in mainwindows.xib
i have the right tab class name "cure"
error
2011-04-29 22:22:06.446 week 3 week clear [4950:40b] -[cure superview]: unrecognized selector sent to instance 0x4e3b7b0
2011-04-29 22:22:06.451 peek 3 week clear [4950:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[cure superview]: unrecognized selector sent to instance 0x4e3b7b0'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc15a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f15313 objc_exception_throw + 44
2 CoreFoundation 0x00dc30bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d32966 ___forwarding___ + 966
4 CoreFoundation 0x00d32522 _CF_forwarding_prep_0 + 50
5 UIKit 0x002e2365 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 77
6 UIKit 0x002e0aa3 -[UIView(Hierarchy) addSubview:] + 57
7 UIKit 0x002e87c1 -[UIView initWithCoder:] + 840
8 Foundation 0x00017c24 _decodeObjectBinary + 3296
9 Foundation 0x00016d91 _decodeObject + 224
10 UIKit 0x004ac979 -[UIRuntimeConnection initWithCoder:] + 212
11 Foundation 0x00017c24 _decodeObjectBinary + 3296
12 Foundation 0x000189f5 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1354
13 Foundation 0x00019024 -[NSArray(NSArray) initWithCoder:] + 596
14 Foundation 0x00017c24 _decodeObjectBinary + 3296
15 Foundation 0x00016d91 _decodeObject + 224
16 UIKit 0x004abc36 -[UINib instantiateWithOwner:options:] + 804
17 UIKit 0x004adab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
18 UIKit 0x00363628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
19 UIKit 0x00361134 -[UIViewController loadView] + 120
20 UIKit 0x0036100e -[UIViewController view] + 56
21 UIKit 0x00373f54 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 120
22 UIKit 0x00372aaa -[UITabBarController transitionFromViewController:toViewController:] + 64
23 UIKit 0x003748a2 -[UITabBarController _setSelectedViewController:] + 263
24 UIKit 0x00374711 -[UITabBarController _tabBarItemClicked:] + 352
25 UIKit 0x002b14fd -[UIApplication sendAction:to:from:forEvent:] + 119
26 UIKit 0x004b3ce6 -[UITabBar _sendAction:withEvent:] + 422
27 UIKit 0x002b14fd -[UIApplication sendAction:to:from:forEvent:] + 119
28 UIKit 0x00341799 -[UIControl sendAction:to:forEvent:] + 67
29 UIKit 0x00343c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
30 UIKit 0x00341750 -[UIControl sendActionsForControlEvents:] + 49
31 UIKit 0x002b14fd -[UIApplication sendAction:to:from:forEvent:] + 119
32 UIKit 0x00341799 -[UIControl sendAction:to:forEvent:] + 67
33 UIKit 0x00343c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
34 UIKit 0x003427d8 -[UIControl touchesEnded:withEvent:] + 458
35 UIKit 0x002d5ded -[UIWindow _sendTouchesForEvent:] + 567
36 UIKit 0x002b6c37 -[UIApplication sendEvent:] + 447
37 UIKit 0x002bbf2e _UIApplicationHandleEvent + 7576
38 GraphicsServices 0x01719992 PurpleEventCallback + 1550
39 CoreFoundation 0x00da2944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
40 CoreFoundation 0x00d02cf7 __CFRunLoopDoSource1 + 215
41 CoreFoundation 0x00cfff83 __CFRunLoopRun + 979
42 CoreFoundation 0x00cff840 CFRunLoopRunSpecific + 208
43 CoreFoundation 0x00cff761 CFRunLoopRunInMode + 97
44 GraphicsServices 0x017181c4 GSEventRunModal + 217
45 GraphicsServices 0x01718289 GSEventRun + 115
46 UIKit 0x002bfc93 UIApplicationMain + 1160
47 peek 3 week clear 0x00002658 main + 102
48 peek 3 week clear 0x000025e9 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
what am i doing wrong?
thank you
You have probably assigned the "cure" class to a UIView in the "Identity" tab in Interface Builder. "cure" is a view controller, so it doesn't implement any UIView methods (such as -superview), and thus throws an exception when trying to load the nib.
Btw, you have a whole bunch of leaks in your code, please read something about memory management in Objective-C (perhaps also about Cocoa naming conventions).