在dismissModalViewControllerAnimated后调用popToRootViewControllerAnimated
我正在工作的应用程序,其中我调用 presentModalViewController
,一旦完成(调用 dismissModalViewControllerAnimated:YES
),它应该立即调用 popToRootViewControllerAnimated
。
但问题是 dismissModalViewControllerAnimated:YES
工作正常,但 popToRootViewControllerAnimated
在它之后不起作用。
代码如下所示:
[self.navigationController dismissModalViewControllerAnimated:YES] ;
[self.navigationController popToRootViewControllerAnimated:YES];
I am working application in which i calling presentModalViewController
and once finished(calling dismissModalViewControllerAnimated:YES
) it should immediately call popToRootViewControllerAnimated
.
But the issue is dismissModalViewControllerAnimated:YES
is working properly but popToRootViewControllerAnimated
is not working after it.
The code is shown below:
[self.navigationController dismissModalViewControllerAnimated:YES] ;
[self.navigationController popToRootViewControllerAnimated:YES];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试这样的事情:
它不是那么整洁,但应该可以工作。
更新:
您应该使用
呈现
模式的对象是视图控制器,而不是导航控制器。
Try something like this:
It is not so neat but it should work.
UPDATE:
You should use
instead
The object that is presenting the modal is the view controller, not the navigation controller.
如果您有一个带有一堆 UIViewController 的导航控制器:
假设,其中调用模态视图控制器的视图控制器具有 navigationController。
If you have a navigation controller with a stack of UIViewControllers:
Assumes, that view controller in which called modal view controller has navigationController.
我遇到了类似的事情。您需要首先复制 self.navigationcontroller 并保留自己,因此当您调用第二个 pop 时,仍然存在对 NC 的引用,并且您仍然存在。
请参阅:如何在一次操作中从 UINavigationController 中弹出一个视图并将其替换为另一个视图?
I ran into something similar to this. You need to make a copy of your self.navigationcontroller first and also retain yourself, so when you call the second pop, there is still a reference to the NC and you still exist.
see : How can I pop a view from a UINavigationController and replace it with another in one operation?
我想,您没有
在目标模式视图控制器中调用。检查一下。
I guess, you are not calling the
in the target modal viewcontroller. check that.