I have a weird design pattern for one of my aps where I have a tool bar that acts as a tab bar. Basically I add this toolbar to all of my view controllers, and the tool bar itself contains pointers to the 3 different nav controllers in my app. When one of the toolbar buttons is pushed, it should be able to remove the nav controller that currently is on the window, and add the one the user has selected. My problem is I’m not sure how to add the new navcontroller to the superview. Would I instantiate an app delegate object and add it to that? Or would I need to send a pointer from my app delegate to the tool bar as a class variable? Any help would be appreciated.
Share
It seems to me that the best way to go about this would be to manage your
UINavigationControllerswitching in your app delegate. You can look after all the cleanup that you need to do during this process here, as well. If there are a finite number ofUINavigationControllers that get switched out, I might just have a few methods to take care of this:App delegate .h file:
App delegate .m file:
Abridged, but you get the idea. This will change if you need to share state between these controllers, though. Do you?
EDIT: In order to access the app delegate, call
[[UIApplication sharedApplication] delegate].