【问题标题】:Pop to the main view controller弹出到主视图控制器
【发布时间】:2013-10-25 23:57:28
【问题描述】:

在我的应用程序中,我有 2 个视图控制器,它们通过使用模态转换出现,现在我开发了第 3 个视图控制器,我放了一个按钮返回到主视图控制器,但是我怎样才能返回到主视图控制器? 我试过这个:

[self dismissViewControllerAnimated:YES completion:nil];

但是有了这段代码,我又回到了第二个视图控制器。我该如何解决?

谢谢!

【问题讨论】:

  • 提供一些代码或解释好你的问题
  • @iPatel 只有在他使用UINavigationController 时才有效,但他使用模式表示视图。
  • @Raon:你需要哪个代码?这是一个界面疑问......如果你喜欢我可以在这里发布一些代码,但我认为它没有用......
  • @iPatel:我会尝试阅读您建议的页面,谢谢

标签: iphone ios uiviewcontroller modalviewcontroller


【解决方案1】:

假设您的第一个模态呈现第二个模态,以下应该可以工作:

__weak UIViewController *vcThatPresentedCurrent = self.presentingViewController;

[self dismissViewControllerAnimated:YES completion:^{

    [vcThatPresentedCurrent dismissViewControllerAnimated:YES completion:nil];
}];

【讨论】:

    【解决方案2】:

    试试这个....

    [self.presentingViewController.presentingViewController
     dismissViewControllerAnimated:YES completion:nil];
    

    如果您有任何问题,请告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 2014-08-27
      • 1970-01-01
      相关资源
      最近更新 更多