Search code examples
iosxcodeglobaluitoolbarnsobject

Is there a way to subclass UIToolbar?


I ask this as I would like a global toolbar in my app (similar to the Facebook app with buttons on it). How do I subclass it so that I can add it on all of my ViewControllers? I've created a new class but UIToolbar isn't in the options. How would I modify NSObject manually?

Edit:

My controller hierarchy is as follows:

A login page, which pushes (flip horizontal) -----> Tab Bar Controller. How would I add this toolbar to the top of each page in the tab bar controller?


Solution

  • If you are using a UINavigationController as your window's root view controller, you can let the navigation controller display a toolbar. You need to tell it to show the toolbar by sending it a setToolbarHidden:animated: message. If you want the toolbar to have the same buttons (or other subviews) in all your view controllers, make sure you set each view controller's toolbarItems property to the same array of items.

    If you are not using a UINavigationController as your window's root view controller, edit your question and describe your view controller hierarchy.