2010-05-12 72 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]; 
相关问题