简体   繁体   中英

UINavigationController from UIViewController

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?

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM