2012-08-08 64 views
0

我有兩個按鈕用於我的UIAlertView。其中一個回到TableViewController而另一個必須去另一個ViewController。進入TableViewController的按鈕可以工作。但是當點擊按鈕時,進入ViewController的按鈕向我顯示空白視圖。UIAlertView按鈕到另一個ViewController

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
if (buttonIndex == 0) 
{ 
    QuizTableViewController *quizTable = [self.storyboard instantiateViewControllerWithIdentifier:@"quizTable"]; 

    UINavigationController *quizController = [[UINavigationController alloc] initWithRootViewController:quizTable]; 
    [quizController setModalTransitionStyle:UIModalTransitionStyleCoverVertical]; 

    [self presentViewController:quizController animated:YES completion:nil]; 
} 

if (buttonIndex == 1) 
{ 
    QuizAnsViewController *quizAns = [[QuizAnsViewController alloc] initWithNibName:nil bundle:nil]; 

    [self presentViewController:quizAns animated:YES completion:nil]; 
} 

} 

代碼的第二部分是用於按鈕以進入另一個ViewController

有人可以幫忙嗎?謝謝。

+0

請問您其他視圖控制器有一個與之關聯的榫文件?如果是這樣,它的名字是什麼?在您的presentViewController:quizAns行之後,請嘗試記錄quizAns.view以確保它不是零。 – rdelmar 2012-08-08 02:56:29

+0

我在ViewController之前插入了一個導航控制器,現在它已經可以工作了。謝謝。 – icee 2012-08-08 03:28:21

回答

-1

你使用NavigationController比我認爲這段代碼是解決你的問題。你可以試試。

if (buttonIndex == 1) 
{ 

     QuizAnsViewController * quizAns = [[[QuizAnsViewController alloc] initWithNibName:@"QuizAnsViewController" bundle:nil] autorelease]; 

    [self.navigationController quizAns animated:YES]; 

} 
0

看來你正在使用的故事板,使這可能工作

if (buttonIndex == 1){ 

    QuizAnsViewController *quizAns = [self.storyboard instantiateViewControllerWithIdentifier:@"Identifier_of_that_view_controller"]; 
    [self presentViewController:quizAns animated:YES completion:nil]; 
} 
相關問題