如何在modelView中保留UINavigationController

时间:2011-12-15 02:21:49

标签: iphone objective-c uinavigationcontroller

我对UINavigationController到ModelView的管理有点困惑。我在RootView中有一个UINavigationController,我想基于RootView从下到上弹出另一个modelView,同时让NavigationController保持在modelView中,这样我仍然可以导航到下一个。如何实现?

2 个答案:

答案 0 :(得分:1)

您可以在RootView中创建导航控制器。假设您要在RootView中单击按钮时显示模态视图:

- (IBAction) showModalView
{
        YourModalView * aYourModalView = [[YourModalView alloc] initWithNibName:@"YourModalView" bundle:nil];
        UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:aYourModalView];
        aYourModalView.navigationController.navigationBar.hidden = YES ;

        [self.navigationController presentModalViewController:navigation animated:YES];
        [aYourModalView release];
}

现在,您的模态视图具有导航控制器,您可以使用以下方式从模态视图中推送VC:

[self.navigationController pushViewController:aViewController animated:YES];

希望它对你有所帮助......

答案 1 :(得分:0)

您可以使用

- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated
<{1}}上的

方法。只是不要设置动画,并将该数组的索引0处的对象更改为新的RootView。