如何在选项卡栏视图中安装NavigationController作为根视图?
在我的应用程序:didFinishLaunchingWithOptions:方法中,我创建了一个选项卡栏界面,将窗口的rootViewController设置为tabBarController。
现在,在我的一个选项卡栏视图中,我想在顶部添加一个导航栏。我如何才能做到这一点呢?
我应该继承navigationcontroller的子类吗?
谢谢
发布于 2010-11-03 20:09:37
听起来你是在代码中做这件事,而不是IB,所以这就是你能做的。
// First create your RootViewController:
UIViewController *rootViewController = [[UIViewController alloc] init];
// Then add the rootViewController to a UINavigationController
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
// Now your RootViewController is a UINavigationController
// Add it to your UITabBarController
[tabBarController.viewControllers addObject:navigationController];
// You can now get rid of the RootViewController and UINavigationController
[rootViewController release];
[navigationController release];https://stackoverflow.com/questions/4084264
复制相似问题