【问题标题】:dismissViewControllerAnimated VS popViewControllerAnimateddismissViewControllerAnimated VS popViewController 动画
【发布时间】:2012-06-20 06:14:32
【问题描述】:

我想知道它们有什么不同。 我什么时候可以打电话

[self dismissViewControllerAnimated:YES completion:nil];

什么时候打电话

[self.navigationController popViewControllerAnimated:YES];

根据苹果的文件: dismissViewControllerAnimated 表示 “关闭接收者呈现的视图控制器。” 但是我总是无法通过这种方法关闭视图控制器。

【问题讨论】:

  • 关于解雇,请参阅斯坦福大学的 this 视频。应始终将dismissViewController 发送到presenting viewController。如果您将 presented viewController 发送给它,并且presentedViewcontroller 没有展示 another viewController then 它会正确关闭它,否则它不会正确执行

标签: ios uiviewcontroller uinavigationcontroller


【解决方案1】:

-dismissViewControllerAnimated:completion:

用于解除UIViewController,由方法呈现:

-presentViewController:animated:completion:.

-popViewControllerAnimated:

UINavigationController的方法用于弹出一个控制器

UINavigationController-pushViewController:animated方法。

在第一种情况下,视图控制器的视图显示为模态控制器(通常从下到上),而在第二种情况下,您将视图控制器推送到UINavigationController 的导航堆栈中。

【讨论】:

    【解决方案2】:

    您选择的应用程序是基于导航的应用程序方式

    [self.navigationController popViewControllerAnimated:YES];
    

    您选择的应用程序不是基于导航的应用程序方式

    [self dismissViewControllerAnimated:YES completion:nil];
    

    【讨论】:

    • 这是否意味着:我不应该在基于导航的应用程序中使用dismissViewControllerAnimated?我想这就是为什么我总是无法dismissViewControllerAnimated的原因,谢谢!
    猜你喜欢
    • 1970-01-01
    • 2013-07-12
    • 1970-01-01
    • 1970-01-01
    • 2014-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多