2011-11-02 38 views
2

我在這個問題上花了差不多一天的時間,有人請幫助我!我試圖從一個tableview控制器推動視圖。它沒有迴應。爲什麼NavigationController不在使用視圖?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
NewsDetailViewController *ndvc = [[NewsDetailViewController alloc] initWithNibName:@"NewsDetailViewController" bundle:nil]; 
[self.navigationController pushViewController:ndvc animated:YES]; 
} 
+2

驗證ndvc不是零。驗證self.navigationController不是零。 – logancautrell

+0

好吧,它似乎是零,它沒有進入。我該怎麼辦? – HardCode

+1

「self.navigationController」爲零或「ndvc」爲零。項目中是否有導航控制器? – beryllium

回答

0

我猜你的self.navigationControllernil。從我得到的意見,你不使用導航控制器。我想說,使用導航控制器創建一個基於窗口的應用程序作爲rootViewController,並在裏面,將tableView添加到navigationController的視圖,然後你應該沒有問題。

+0

那麼,我需要提到我的tableViewController是在tabViewController中。你認爲是tabViewController導致這個問題? – HardCode

+1

不需要。您需要將navigationController放在tabViewController中,並且需要添加'tableView'。 – Legolas

+0

明白!謝謝:) – HardCode

0

您的NewsDetailViewController可能會覆蓋initWithNibName函數。使用斷點來查看爲什麼返回零。確保你傳遞正確的NIB文件名(即確保你的項目中存在NewsDetailViewController.xib)

相關問題