Trying to place a UINavigationController as one of the tabs inside a UITabBarController
I'm writing an iphone app that has 3 tabs. The first two are UITableViews, but the third tab i want to be a UINavigationController, because it is to be used for editing a list of recipes.
I've tried every 开发者_如何学Pythoncombination of nibs i could think of to get this to work properly but am having problems such as:
- once you click on the editing tab, then click back to the other tabs, the display still shows parts of the editing tab such as the navigation bar
- when you click on the editing tab, you can see a blank navigation controller with no contents or title, even though my nav controller inside the tabs has the 'nib name' and the 'class' set in the inspector
I just would like to know the best way of going abouts doing this: putting an editor (which i think should be a navigation controller?) inside a tab. Is there something glaring i'm missing?
Thanks so much guys
I use to do editing buttons with navigation controller as well and it woks very well, so this is probably good option.
If you want navigation controller just for one view you need to hide it by switching tabs
self.navigationController.navigationBarHidden = YES; or NO
And since I don't use IB (it is black box) I would recommend you to allocate all (title, buttons, etc.) about navigation controller manually. Works great and you see what you've done.
OK i solved it. I was on the right track already anyway.
My main window now has a tab bar controller. One of the tabs has its nib name and class set to my view with navigation.
In my view with navigation, in the nib i have an empty view and a navigation controller. In the implementation file, i have the following code to attach the nav controller into the empty view, and it works nicely now!
- (void)viewDidLoad {
[super viewDidLoad];
[[self view] addSubview:navController.view]; // This is the important line
}
精彩评论