0

我已经实现了一个方法 didSelectRowAtIndexPath 应该推送另一个视图。我有一个使用navigationController 正确运行的代码,但在这种情况下,我在视图上使用navigationItem 。我怎么能触发视图?谢谢

错误日志:

2010-03-25 00:09:52.459 TableArchive[1062:207] trigger
2010-03-25 00:09:52.461 TableArchive[1062:207] *** -[UINavigationItem pushViewController:animated:]: unrecognized selector sent to instance 0x3921ca0
2010-03-25 00:09:52.462 TableArchive[1062:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UINavigationItem pushViewController:animated:]: unrecognized selector sent to instance 0x3921ca0'
2010-03-25 00:09:52.463 TableArchive[1062:207] Stack: (


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
 NSLog(@"trigger");

 if(dvController == nil) {
   DetailView *aController =[[DetailView alloc]initWithNibName:@"DetailView" bundle:nil];

   self.dvController = aController;

   [aController release];
 }

 [[self navItem]pushViewController:dvController animated:YES];

 [dvController release];
}
4

2 回答 2

1

显然你不能这样做[[self navItem]pushViewController:dvController animated:YES];,因为 aUINavigationItem不是 a UINavigationController

你必须[[self navigationController] pushViewController:dvController animated:YES];改用。除此之外,我不明白你在问什么。

于 2010-03-24T23:56:38.273 回答
0

您需要将视图中的 UINavigationItem(XIB ?)设置为您的 UINavigationController 导航项。您可以通过将 IBOutlet 设置为 navItem 并在您的代码中执行 self.navControllet.navItem = navItem (类似的东西)来做到这一点。

于 2010-12-21T17:48:33.873 回答