0

我有一个使用这两个教程设置的项目,第二个教程的链接在第一个教程的底部。

该教程有点过时,但我设法让它像宣传的那样工作。现在我想在NavigationController用户触摸表格视图中的一行时将一个新的 detailView 推送到。

所以我把它添加到我的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从 nib 加载时遇到问题,但是我检查了detailViewController它,它不是 nil。

我知道我遗漏了一些东西,而且很可能是一些简单的东西。

请帮忙。

4

1 回答 1

1

好的,正如我所说,我错过了一些简单的修复方法是从笔尖名称中删除 .xib 。

//change line SecondViewController *detailViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController.xib" bundle:nil];
//to
 SecondViewController *detailViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
于 2010-05-12T18:53:53.650 回答