2010-05-12 39 views
0

我有一個使用這兩個tutorials設置的項目,第二個教程的鏈接位於第一個的底部。如何從tabviewController中將另一個viewController拖放到navigationController上?

該教程略有過時,但我設法讓它按照廣告的方式工作。現在,我想在用戶觸摸表視圖中的某行時將新的詳細視圖推送到NavigationController

因此,我已將此添加到我的MyTableViewController.m文件中。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    // Navigation logic may go here. Create and push another view controller. 

    SecondViewController *detailViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController.xib" bundle:nil]; 
    // ... 
    // Pass the selected object to the new view controller. 

    [self.navigationController pushViewController:detailViewController animated:YES]; 
    [detailViewController release]; 
} 

現在,當我運行該項目,並在我的表視圖觸摸行,我得到一個錯誤:

asm_Terminating_due_to_uncaught_exception 

IT似乎有裝載從筆尖SecondViewController的問題,但是我查detailViewController,它不是零。

我知道我錯過了一些東西,它很可能是一件簡單的事情。

請幫忙。

回答

1

好吧,我說我錯過了一些簡單的修復方法是從nib名稱中刪除.xib。

//change line SecondViewController *detailViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController.xib" bundle:nil]; 
//to 
SecondViewController *detailViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; 
相關問題