关闭viewcontroller并执行segue [英] Dismissviewcontroller and perform segue

查看:31
本文介绍了关闭viewcontroller并执行segue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 performSegueWithIdentifier 去另一个视图控制器,但我还需要删除我当前所在的视图控制器.我该怎么做,我试过这个,但它不起作用:

I need to go to another viewcontroller with performSegueWithIdentifier but I also need to remove the viewcontroller I'm currently in. How can I do this, I have tried this but it doesn't work:

[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 个视图控制器,它们是这样连接的,我想从游戏结束到高分.

It looks like there isn't any easy way to do this? I have 4 viewcontrollers, they are connected like this, and I want to go from gameover to highscore.

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

推荐答案

这个怎么样?

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

这篇关于关闭viewcontroller并执行segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆