如何在tableview中推送一个新的viewController,这是一个navigationcontroller的插入视图?
我有一个HomeViewController.m,我在其中按
self.navigationController
推送SpecificViewController,
SpecificViewController *specificViewController= [[SpecificViewController alloc] initWithNibName:@"SpecificViewController" bundle:nil];
[self.navigationController pushViewController:specificViewController animated:YES];
在SpecificViewController.m中,我插入一个子视图
FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
[self.view insertSubview:firstViewController.view atIndex:0];
在FirstViewController.m中,有一个tableview。问题是如何通过navigationController推送一个新的ViewController,我在下面尝试,但它不起作用。
-(void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailTableViewController *detail =
[[DetailTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
[self.navigationController pushViewController:detail animated:YES];
[detail release];
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
我还是尝试了一个新的UINavigationController,
UINavigationController *NEWnavigationController;
NEWnavigationController=[[UINavigationController alloc] init];
[NEWnavigationController pushViewController:detail animated:YES];
但它仍然无效。你能给我任何建议吗?
没有找到相关结果
已邀请:
1 个回复
铰齐插
这将确保您的Navigation控制器已设置,并且出现的第一个视图控制器是SpecificViewController 其次,您不要将视图控制器作为子视图插入。如果您尝试加载第二个视图控制器,则将其推送到导航控制器堆栈。您可以从SpecificViewController执行此操作,如下所示