Question

I'm trying to go back into a ViewController using popoverviewcontroller, but nothing happens.
First, I'm loading the first ViewController, in the AppDelegate, with this code:

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.welcomeMenu];
nav.navigationBarHidden = YES;
self.window.rootViewController = nav;
nav = nil;

The navigationBar is hidden because I need it in that way
In this ViewController, I'm showing a menu with buttons, then, to show another ViewController, I'm using this code:

SecondViewController *secView = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];

[UIView  beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController:secView animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
secView = nil;

And the SecondViewController loads (but the rotation doesn't work)...
My SecondViewController adds in code a SplitViewController (with a NavigationController for the Table on the left, and another NavigationController for another table on the right)
Then, in the SecondViewController, I'm adding manually a button to go back, using this code:

[self.navigationController popViewControllerAnimated:NO];

but nothing happens... When I print self.navigationController, the output is (null), so I guess this is the problem, but why my self.navigationController is null? And What I need to do to pop correctly?
If I don't hide the navigationBar in the AppDelegate code, the backButton that appears automatically works fine, but when I want to do it, manually, does not work...

Was it helpful?

Solution

You cannot load a split view controller from your SecondViewController.

See Split View Controllers:

A split view controller must always be the root of any interface you create. In other words, you must always install the view from a UISplitViewController object as the root view of your application’s window. The panes of your split view interface may then contain navigation controllers, tab bar controllers, or any other type of view controller you need to implement your interface. Split view controllers cannot be presented modally.

OTHER TIPS

You never added SecondViewController to the navigation controller's viewControllers, that's why self.navigationController logs null, so just update the viewControllers array with your new controller.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top