2012-11-14 75 views
1

请帮助我。如何解除现有视图控制器后再显示其他视图控制器?这里是我的代码:显示另一个ViewController

- (void)matchmakerViewControllerWasCancelled: 
(GKMatchmakerViewController *)viewController{ 

    [self dismissModalViewControllerAnimated:YES]; 

    ViewController *Vc = [[ViewController alloc]init]; 
    [self presentModalViewController:Vc animated:YES]; 



} 

我的代码不起作用。请帮帮我。如果我解雇了ModalViewController后写了NSLog,它显示我NSLog,但ViewController不会显示。谢谢

+0

ViewController是否有任何视图(您是否有ViewController的xib文件)? – rdelmar

回答

4

[self dismissModalViewControllerAnimated:YES];已被弃用。尝试这样做:

- (void)matchmakerViewControllerWasCancelled: 
(GKMatchmakerViewController *)viewController{ 

    [self dismissViewControllerAnimated:YES completion:^{ 
     ViewController *Vc = [[ViewController alloc]init]; 
     [self presentViewController:Vc animated:YES completion:^{}]; 
    }]; 
} 
+0

+1。它可以在完成块中呈现。 – iDev

0

只需点击这个

[self dismissModalViewControllerAnimated:NO]; 
Nextview *sec = [[Nextview alloc] initWithNibName:@"Nextview" bundle:nil]; 
[self presentModalViewController:sec animated:YES]; 
[sec release]; 

希望这个作品。

相关问题