views:

225

answers:

1

In a tab bar based app, I add a new UIViewController from tabview1 like this

[self.view addSubview:self.aView.view];

I created the nib for aView in IB. It is a view with a tableview and navigation bar. I have aView and bView, which are nearly the same and added to the parent the same way. The only difference is that aView has two sections in its tableview. Otherwise, the views are laid out the same.

For some reason, aView does not display its navigation bar. It also seems to sit a little higher than bView, since I can see a sliver of the parent view between the tab bar and aView. I've tried to find any differences between these two views that would cause this behavior but can't. What am I overlooking?

+1  A: 

Depending on your needs you should be able to create separate nib's for each UIViewController then set each of these nib's to be loaded as the first view controller in each tar of the tabbar, or with the same nib's set these in each bar with:

- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated

The following info from the Apple docs should help:

http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/TabBarControllers/TabBarControllers.html#//apple_ref/doc/uid/TP40007457-CH102-SW14

http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/TabBarControllers/TabBarControllers.html#//apple_ref/doc/uid/TP40007457-CH102-SW15

petert
Each nib does have a view controller. Setting them as the first view controller isn't what I want. This views only display in special cases and lay on top of the tab bar view controller.
4thSpace
Okay, I see. Could you possibly use a modal view controller that can be displayed over the top?
petert
Thanks. I tried the modal and the one view is still loading without its navigation bar, where as the other does load with it.
4thSpace
I made a copy of aView and named it "aView copy". Then I removed bView. I put all of bView's code in "aView copy". I also copied aView.xib. The copy now works fine. I'll stick with that since I can't figure out what happened to bView.
4thSpace
Good to hear you've something working - I was away for a week, hence the silence. Just a follow-up: your comment about no navigation bar in a view - I guess you know it's easy to add your view to a boiler-plate instance of UINavigationController and then push this navigation controller modally. Now you have a navigation bar.
petert