[英]iOS presented UINavigationController gets dismissed after it performs a popViewController
In my app i present a UINavigationController
modally with a UIViewController
as its rootViewController
. 在我的应用程序中,我以模态形式呈现了一个UINavigationController
并将UIViewController
作为其rootViewController
。 I do it in form style. 我以表单样式进行操作。 I added a second UIViewController
which is also in form style and i can push to it fine. 我添加了第二个同样也是表单样式的UIViewController
,我可以很好地进行介绍。 However when i perform a popViewController
action after the second UIViewcontroller
gets popped onto the first, the whole modally presented UIViewController
gets dismissed. 但是,当我在将第二个UIViewcontroller
弹出到第一个popViewController
之后执行popViewController
动作时,整个模态呈现的UIViewController
都会被关闭。 However i don't perform any dismissing and the dismissing function doesn't get triggered by accident either. 但是我不执行任何解除操作,并且解除功能也不会意外触发。
Any ideas why it's happening? 有什么想法为什么会发生吗?
Sincerely, 真诚的
Zoli 佐利
EDIT: 编辑:
That's how i'm presenting the modal viewcontrollers with a navcontroller: 这就是我向模式视图控制器提供navcontroller的方式:
if(!welcomeScreenAlreadyPresented) {
welcomeScreenViewController = [[WAWelcomeViewController alloc]init];
}
welcomeScreenNavController = [[UINavigationController alloc]initWithRootViewController:welcomeScreenViewController];
[welcomeScreenNavController setModalTransitionStyle: UIModalTransitionStyleCrossDissolve];
[welcomeScreenNavController setModalPresentationStyle:UIModalPresentationFormSheet];
[welcomeScreenNavController setNavigationBarHidden:YES animated:NO];
[self.navigationController presentViewController:welcomeScreenNavController animated:YES completion:nil];
That's how i'm navigation in WAWelcomeViewController.m 这就是我在WAWelcomeViewController.m中导航的方式
registerViewController = [[WARegisterViewController alloc]init];
[self.navigationController pushViewController:registerViewController animated:YES];
And in WARegisterViewController.m that's how i pop back 在WARegisterViewController.m中,这就是我弹出的方式
[self.navigationController popViewControllerAnimated:YES];
What you need to do is put the viewController you want to push inside another UINavigationController
. 您需要做的是将要推送的viewController放入另一个UINavigationController
。
registerViewController = [[WARegisterViewController alloc]init];
UINavigationController *modalNavigationController = [[UINavigationController alloc] initWithRootViewController:registerViewController]; // autorelease if you are not using ARC
[self presentViewController:navController animated:YES completion:^{}];
You might want to add the modalNavigationController
as a property to later call popViewControllerAnimated:
on it. 您可能需要将modalNavigationController
添加为属性,以便稍后对其调用popViewControllerAnimated:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.