问题描述
我的故事板正在使用 UINavigationController
(VC0),我继续使用 UIPopover
加载新的 UIViewController
(VC1).从这个新的 UIViewController
,我弹出一个新的 UIViewController
(VC2).当我尝试关闭这个最新的弹出框时,我正在退出 UINavigationController
.
My storyboard is using a UINavigationController
(VC0), I segue using a UIPopover
to load a new UIViewController
(VC1). From this new UIViewController
, I am popping to a new UIViewController
(VC2). When I attempt to close this newest popover, I am being quit back to the UINavigationController
.
我在 VC0 中用于将 VC1 显示为弹出框的代码,VC1 到 VC2 是相同的代码(尽管标识符不同):
The code that I'm using in VC0 to show the VC1 as popover, VC1 to VC2 is the same code (different identifier though):
[self performSegueWithIdentifier:@"titlePopover" sender:self];
我在 VC2 中用来关闭弹出框的代码是:
The code that I'm using in VC2 to dismiss the popover is:
UIViewController *vc = [self presentingViewController];
[self dismissViewControllerAnimated:YES completion:^{
[[vc presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}];
它所做的是关闭 VC2,显示 VC1 一瞬间,然后关闭 VC1 并返回到 VC0.我只想关闭 VC2,这样我就可以使用 VC1
What it does is dismisses VC2, shows VC1 for a split second, then dismisses VC1 and goes back to the VC0. I want to be able to dismiss VC2 only, so that I'm on VC1
推荐答案
如果以模态方式执行 sugue
,请使用代码导航:
If you performing sugue
modally, use code navigate back:
[self dismissViewControllerAnimated:YES completion:nil];
如果执行推segue
,使用代码导航回来:
If performing push segue
, use code to navigate back:
[self.navigationController popViewControllerAnimated:YES];
这篇关于从另一个 Popover 中关闭显示为 Popover segue 的 ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!