我想知道它们的不同之处。 当我可以打电话
[self dismissViewControllerAnimated:YES completion:nil];
什么时候打电话给
[self.navigationController popViewControllerAnimated:YES];
根据苹果的文件: dismissViewControllerAnimated意味着 “驳回接收者提供的视图控制器。” 但我总是不能通过这种方法解雇视图控制器。
答案 0 :(得分:39)
您选择的应用程序是基于导航的应用程序
[self.navigationController popViewControllerAnimated:YES];
您选择的应用程序不是基于导航的应用程序
[self dismissViewControllerAnimated:YES completion:nil];
答案 1 :(得分:38)
<强> -dismissViewControllerAnimated:完成:强>
用于解除由{}隐藏的UIViewController
:
-presentViewController:animated:completion:
。
<强> -popViewControllerAnimated:强>
UINavigationController
的方法用于弹出
-pushViewController:animated
的 UINavigationController
方法。
在第一种情况下,视图控制器的视图显示为模态控制器(通常从下到上),第二种情况是您在UINavigationController
的导航堆栈中推送视图控制器。