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

标签 ios objective-c uiviewcontroller uinavigationcontroller uipopovercontroller

我的 Storyboard使用 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];

关于ios - 从另一个 Popover 中关闭显示为 Popover segue 的 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42671732/

相关文章:

ios - 在范围内找不到类型 'GADInterstitial'?

ios - 如何在页脚中使用 segue 将标签数据传递到不同的部分?

ios - ABPeoplePickerNavigationController shouldContinueAfterSelectingPerson 返回搜索结果

ios - 导航 Controller 无法正常工作

Swift - 从滑入式菜单中打开 UIViewController

ios - 过滤器 UISearchController 之后的 didSelectRowAtIndexPath indexpath - Swift

android - 在免费的 Heroku 帐户上部署 Android/iOS 应用程序以进行 Stripe 支付

ios - 如何使用印度卢比将 NSInteger 转换为 objective-c 中的相应单词

ios - UILocalNotification 和 applicationIconBadgeNumber 的良好模式

ios - 在另一个 View Controller 中传递 ImagePickerView 的图像