I have a rootViewController that is a UITabBarController. A UIToolBar is present in that controller since it has a SearchBar that is global to the app. In certain tabs, there should be specific UIBarButtonItems, or UISegmentedControl, along with the searchBar. In other tabs, there should be nothing in the toolBar, just a title.
What is a good way to lay out the view? Currently based on what tab is selected, the main toolBar from the rootViewController is either used as it is, have a UISegmentedControl added to it, hidden completely and replaced with another viewController that has its own toolbar, etc. To me, I’m thinking that each viewController that is present in its own tab can have its own ToolBar, and reference the global functionality, vs hiding/showing different toolbars.
sorry if this is a convoluted question. Just wondering if people had experience with this. Thanks.
The short answer is that there isn’t really a good way to do this. If you’re using a tab bar controller, the tab bar will always be visible along the bottom of your screen. Presumably each tab is a
UINavigationControllerwith a navigation bar at the top. There’s not an appropriate place to put toolbar buttons in this layout.A better design could be to abandon the
UITabBarControllerand use aUINavigationControlleras your root view controller. Instead of tabs, you can have a table view with an item for each view of your application. Then you’ll have room for a toolbar at the bottom of the screen. In fact,UINavigationControllersupports having a toolbar at the bottom. You just override thetoolbarItemsproperty to return the items that should appear in each of the child view controllers. You’ll just need to settoolbarHiddentoNOon theUINavigationController, and you’re good to go.