4

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

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

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

4 回答 4

6

这个怎么样?

UIViewController *parentController = self.presentingViewController;
[picker dismissViewControllerAnimated:YES completion:^(void){
    [parentController performSegueWithIdentifier:@"next" sender:self];
}];
于 2012-12-05T23:35:29.907 回答
1

我有同样的问题,如果有人来这里寻找答案,这就是我要解决的问题。

//In viewController that is being dismissed
[self dismissViewControllerAnimated:NO completion:^{
     [[NSNotificationCenter defaultCenter] postNotificationName:@"callSegue" object:self];
}];


//In viewController being presented
//in viewDidLoad:
[[NSNotificationCenter defaultCenter] addObserver: self
                                             selector: @selector(gotoNewView)
                                                 name: @"callSegue"
                                               object: nil];

-(void)gotoNewView {
    [self performSegueWithIdentifier:@"segueToPerform" sender:self];
}
于 2014-02-11T15:00:59.227 回答
0

在我意识到我应该使用 push segue 之前,我遇到了同样的问题。
新 VC 将立即解雇他们两个。

于 2013-01-31T19:21:40.880 回答
0

更好的是:

[self dismissViewControllerAnimated:NO completion:^(void)
{
 // Perform the segue here.
}];
于 2015-05-28T02:06:48.653 回答