【问题标题】:Dismissing a ViewController shown as Popover segue from within another Popover从另一个 Popover 中关闭显示为 Popover segue 的 ViewController
【发布时间】:2017-03-08 12:44:16
【问题描述】:

我的故事板使用UINavigationController(VC0),我继续使用UIPopover 加载新的UIViewController (VC1)。从这个新的UIViewController,我跳到一个新的UIViewController (VC2)。当我尝试关闭这个最新的弹出窗口时,我将退出UINavigationController

我在 VC0 中使用的代码将 VC1 显示为弹出框,VC1 到 VC2 是相同的代码(尽管标识符不同):

[self performSegueWithIdentifier:@"titlePopover" sender:self];

我在 VC2 中用来关闭弹出框的代码是:

UIViewController *vc = [self presentingViewController];
[self dismissViewControllerAnimated:YES completion:^{
    [[vc presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}];

它的作用是关闭 VC2,显示 VC1 片刻,然后关闭 VC1 并返回到 VC0。我希望能够只关闭 VC2,以便我在 VC1 上

【问题讨论】:

  • 您只想解雇 VC2 而不是 VC1?
  • @NiravD,是的。只需关闭 VC2
  • 下面的答案对你有帮助吗?
  • @NiravD 是的,[self dismissViewControllerAnimated:YES completion:nil]; 对我有用。

标签: ios objective-c uiviewcontroller uinavigationcontroller uipopovercontroller


【解决方案1】:

如果您以模态方式执行sugue,请使用代码导航返回:

[self dismissViewControllerAnimated:YES completion:nil];

如果执行推送segue,使用代码导航返回:

[self.navigationController popViewControllerAnimated:YES];

【讨论】:

  • [self dismissViewControllerAnimated:YES completion:nil]; 在我的情况下为我工作。谢谢
  • 乐于助人:)
猜你喜欢
  • 2014-04-14
  • 1970-01-01
  • 2012-11-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多