views:

501

answers:

1

I Have an UITabbar app with an imbedded Navigation Controller which is loading table views.

I would like to add a mini toolbar beneath the navigation bar, with a segmented control to sort table data by group or by name.

I have tried this with interface builder, trying to add the toolbar to both the table view controller and the navigation controller, hooking up the toolbar to the files owner, but no matter what I try the toolbar won't show up.

I have tried in code using to create the toolbar in the UITableViewController, but the toolbar then scrolls with the table.

I have tried to unhide the toolbar in the navigation controller with...

[self.navigationController setToolbarHidden:NO];

and to setItems with an array to add buttons, but all I can get is a blank toolbar right above the tabbar.

Any help with this would be greatly appreciated.

Thanks.

+2  A: 

The toolbar included in UINavigationController is, as you observed, displayed at the bottom, above the tab bar. You shouldn't change its location. The reason you get a blank toolbar is that you probably called setToolbarItems: on the wrong controller. It should be called on the displayed view controller itself, not the navigation controller like this:

[self.navigationController setToolbarHidden:NO];
[self setToolbarItems:items];

On the other hand, if you want to display a toolbar at the top, under the navigation bar, you should use a UIViewController that has a UIToolbar and a UITableView as its subviews, instead of a UITableViewController.

Can Berk Güder
Thanks for the tip! Adding my UITableView and UIToolbar to the ViewController worked perfectly. I was having some trouble with loading the table data in the new ViewController, but just had to revisit the delegate and datasource connections and now everything is in order. Thanks again!
solon29
You're welcome. Please accept my answer if it worked for you.
Can Berk Güder