简体   繁体   中英

popviewcontroller does nothing, doesn't work

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...

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.

您从未将SecondViewController添加到导航控制器的viewControllers,这就是self.navigationController记录为null的原因,因此只需使用新控制器更新viewControllers数组。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM