从另一个 Popover 中关闭显示为 Popover segue 的 ViewController

Dismissing a ViewController shown as Popover segue from within another Popover

我的故事板使用 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

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

[self dismissViewControllerAnimated:YES completion:nil];

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

[self.navigationController popViewControllerAnimated:YES];