ios 解雇ViewControllerAnimated VS popViewControllerAnimated
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11080091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
dismissViewControllerAnimated VS popViewControllerAnimated
提问by kevin young
I want to know what is the different of them. when I can call
我想知道他们有什么不同。我什么时候可以打电话
[self dismissViewControllerAnimated:YES completion:nil];
and when I should call
什么时候我应该打电话
[self.navigationController popViewControllerAnimated:YES];
according document of apple: dismissViewControllerAnimated means "Dismisses the view controller that was presented by the receiver." But I always fail to dismiss view controller by this method.
根据苹果的文档:dismissViewControllerAnimated 表示“关闭接收器呈现的视图控制器”。但是我总是无法通过这种方法关闭视图控制器。
回答by Senthilkumar
your selected application is navigation based application means
您选择的应用程序是基于导航的应用程序手段
[self.navigationController popViewControllerAnimated:YES];
your selected application is other than the navigation based application means
您选择的应用程序不是基于导航的应用程序方式
[self dismissViewControllerAnimated:YES completion:nil];
回答by graver
-dismissViewControllerAnimated:completion:
-dismissViewControllerAnimated:完成:
Used to dismiss an UIViewController
, which was presented by the method:
用于关闭UIViewController
,由方法提供:
-presentViewController:animated:completion:
.
-presentViewController:animated:completion:
.
-popViewControllerAnimated:
-popViewControllerAnimated:
Method of UINavigationController
is used to pop a controller shown by
的方法UINavigationController
用于弹出一个控制器
-pushViewController:animated
method of UINavigationController
.
-pushViewController:animated
的方法UINavigationController
。
In the first case the view controller's view shows as a modal controller (usually from bottom to top), and the second case you are pushing a view controller in the navigation stack of UINavigationController
.
在第一种情况下,视图控制器的视图显示为模态控制器(通常从下到上),第二种情况下,您将视图控制器推送到UINavigationController
.