2010-08-13 52 views
0

我有一個UITableViewController作爲我的標籤欄控制器的第二個選項卡上的視圖控制器之一。UITableViewController detailView從未推

didSelectRowAtIndexPath我創建了一個詳細的視圖控制器,但它從來沒有被推到導航堆棧上...並且應用程序也不會崩潰,因爲我可以在調用pushViewController之後調用NSLog。

這是方法:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    KeyboardViewController *v = [[KeyboardViewController alloc] initWithNibName:@"KeyboardView" bundle:nil]; 
    [self.navigationController pushViewController:v animated:YES]; 
    NSLog(@"gets here OK"); 
} 

什麼會導致此?當然,如果navigationController不存在,那麼它會崩潰?由於這是一個UITableViewController,它應該自動創建,如果它不是?

感謝

+0

奇怪...你確定一切都存在的方式應該??嘗試使用該方法的斷點進行調試...因此,您會看到分配的內容以及哪些不是... – dododedodonl 2010-08-13 12:15:33

回答

3

當然,如果navigationController不存在,那麼它會崩潰?

不,[nil方法]不會崩潰。

既然這是一個UITableViewController,它應該自動創建它應該不是?

默認情況下,UITableViewController沒有UINavigationController。您必須將UITableViewController放在UINavigationController中。