objective-c - 关闭 Viewcontroller 并执行 segue

标签 objective-c ios uiviewcontroller segue

我需要使用 performSegueWithIdentifier 转到另一个 View Controller ,但我还需要删除我当前所在的 View Controller 。我该怎么做,我试过这个但它不起作用:

[self performSegueWithIdentifier:@"next" sender:self];
[self dismissViewControllerAnimated:NO completion:nil];

//tried the other way, but it doesn't work either
[self dismissViewControllerAnimated:NO completion:nil];
[self performSegueWithIdentifier:@"next" sender:self];

看起来没有任何简单的方法可以做到这一点? 我有 4 个 View Controller ,它们是这样连接的,我想从游戏结束到高分。

menu-->game----->gameover
menu-->highscore

最佳答案

这个怎么样?

UIViewController *parentController = self.presentingViewController;
[picker dismissViewControllerAnimated:YES completion:^(void){
    [parentController performSegueWithIdentifier:@"next" sender:self];
}];

关于objective-c - 关闭 Viewcontroller 并执行 segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13733263/

相关文章:

ios - 将 UI 滑动手势识别添加到自定义 View ios

ios - 使用 alamofire 上传多个图像,而不使用 swift 中的 for 循环

iphone - 被分析的二进制文件必须存在,xcode 中的 iOS App Archive

ios - 呈现具有自定义大小的 UIViewController

ios - MFMailComposeViewController 删除 rootViewcontroller

objective-c - 显示带有许多可点击 URL 的文本

objective-c - 在 Objective-C 中相互引用类和子类化

iphone - 调试构建工作得很好,临时构建很难崩溃

ios - 释放与导航 Controller 关联的 View Controller

objective-c - 如何理解这个崩溃日志