UINavigationController crashed app in iOS SDK 4.2

I am transferring the application to the current SDK for iOS. Its root controller UINavigationControllerwith another UINavigationControlleras the first view controller.

The application now crashes with EXC_BAD_ACCESScaused by some kind of infinite recursion, but I can not understand the straw trace. As far as I can tell, nothing has changed, waiting for some project settings so that it compiles the current SDK.

I created a new navigation application and added a nested UINavigationControllerone that also crashed the application. Is nesting a UINavigationControllerbad idea at all?

Any hints that may cause this or how to interpret the stack trace and debug the problem are welcome.

+1
source share
3 answers

It will work if, before loading the view, before installing the navigation panel interface of the parent navigation controller, it is necessary to set the hidden one (in the interface constructor or in the code):

navigationController.navigationBar.hidden = YES;
[self.window addSubview:navigationController.view];
+3
source

Well, it seems weird to have a nested UINavigationController, but what the hell I know. What is the root view controller of a nested controller? Hope this is not the topmost controller.

+1
source

:

  • UINavigationController
  • viewDidLoad viewWillLoad , root .
  • NavigationController subview viewCntroller view ( self.contentView)

BOOM!!

.

- (void)viewDidLoad
{
[super viewDidLoad];
[self.contentView setFrame:CGRectMake(0, 0, self.contentView.bounds.size.width, self.contentView.bounds.size.height)];

mNavController =[[UINavigationController alloc]initWithRootViewController:myNestedRootController]; /
[self.mNavController.view setFrame:CGRectMake(0, 0, self.contentView.bounds.size.width, self.contentView.bounds.size.height)];
[self.mNavController setNavigationBarHidden:YES]; //optional
[self.contentView addSubview:self.mNavController.view];
}

Actually you can skip ContentView and have a view mNavController'sdirectly on viewcontroller view(my bad)

I have a way to click (just click) a new VC

-(void)moveToContentViewController:(PM_BaseContentVC *)contentvc animated:(BOOL)animated{
[self.mNavController popToRootViewControllerAnimated:NO]; //silently pop the previous viewcontroller
[self.mNavController pushViewController:contentvc animated:YES]; //push new viewcontrolelr
[self.contentView addSubview:self.mNavController.view]; //add the view
}

sugestions and optimization are welcome :)

0
source

All Articles