0

这就是我在 TalbeViewController.m 中尝试做的事情:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:TRUE];
  if(indexPath.row==0) {

      //Initialize the detail view controller and display it.
      OmDetail1ViewController *firstDetailController = [[OmDetail1ViewController alloc] initWithNibName:@"OmDetail1ViewController" bundle:nil];
      [self.navigationController pushViewController:firstDetailController animated:YES];
      [firstDetailController release];
}
else if(indexPath.row==1) {
 //The second DetailView
}
else if(indexPath.row==2) {
 //The third DetailView
}
 }

这就是我在选择第一个单元格时被告知的内容:

2012-07-17 14:17:42.660 TheApp [4635:f803] * * * 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法在包中加载 NIB:“NSBundle(已加载)”,名称为“OmDetail1ViewController” “ *第一掷调用堆栈:(0x13d5022 0x1566cd6 0x137da48 0x137d9b9 0x240638 0xe61fc 0xe6779 0xe699b 0xe6d11 0xf88fd 0xf8aef 0xf8dbb 0xf985f 0xf9e06 0xf9a24 0x2f90 0xb05c5 0xb07fa 0x94585d 0x13a9936 0x13a93d7 0x130c790 0x130bd84 0x130bc9b 0x12be7d8 0x12be88a 0x1f626 0x28c2 0x2835)终止叫做抛出异常(LLDB)

除了在 TableViewController.m 中导入“OmDetail1ViewController.h”之外,我没有做任何其他事情来连接视图。在 IB 中,我在实用程序中设置了正确的类,但什么也没做,没有建立任何连接。

4

1 回答 1

0

问题不在于那段代码。而是在您的 OmDetail1ViewController 类中,检查您是否在 IB 中为 ViewController 正确设置了视图,并且名称匹配。

在 IB 中,您的视图应设置为“文件所有者”,如果您选择文件所有者,则在自定义类中它应该有您的 OmDetail1ViewController 类。

于 2012-07-17T12:43:39.747 回答