2012-11-14 80 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]; 

希望這個作品。

相關問題