views:

129

answers:

1

I currently have this workflow in a tab based app:

Tab1 loads...

ViewOne : UIViewController
  >> 
    PickerView : UIViewController
    >> 
       DetailView : UIViewController

">>" means loads based on user action. I'd like navigation bars on PickerView and DetailView. PickerView just needs a cancel button in the top left of its nav bar. DetailView needs the normal navbar back button. I already have PickerView's nav bar wired up through IB and working. I'm not sure what to do with PickerView's nav bar.

PickerView is also loaded from Tab2, who's main view starts as a UINavigationController. PickerView's nav bar works fine in that case.

ViewOne should not have a navigation bar.

Any ideas?

+1  A: 

Sounds like you just do the usual: in ViewOne, create your nav controller as:

UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:picker];
[self.view addSubview:nc.view];
[nc release];

Back buttons are created automatically (unless you need one to get back from your picker to viewOne, in which case create one.

Sounds like you want to present DetailView as a modal:

[self presentModalViewController:detailView animated:YES];

although you could just use it within a navigation controller normally.

Sounds like you are perhaps worrying too much about the mechanics of navigation when the navigation controller can do it all for you?

Paul Lynch
It actually needs to be addSubview:nc.view. When I do this, the added view is pushed down enough that I can see the first view behind it. Seem like the same amount of space that the status bar takes up. Do you have any ideas what causes this?
4thSpace
Paul Lynch
4thSpace
I had to add this bit of code to make it work: self.nc.view.frame = CGRectMake(0, 0, 380, 460);
4thSpace