mluisbrown
mluisbrown

Reputation: 14918

How can I have a UITabBar instead of a UIToolBar on a UINavigationController?

I have UINavigationController with UITableViewController as the root view controller. UINavigationController has a an optional UIToolBar, but I want to have a UITabBar instead. I don't need a UITabBarControllerbecause I don't want selecting tab bar items to change the view, just the contents of the same view. My app is a basic RSS reader which displays the items in the table view and I want to use the UITabBar to select from 2 or 3 different RSS feeds, refreshing the existing table view in the process, not switching to a different table view.

If I add a UITabBar manually to the UITableViewController (as it seems impossible to do this form IB) it is anchored to the last cell in the table view, so not only is it not usually visible, but it also moves around. I can't seem to find any way to do what I want.

Upvotes: 0

Views: 243

Answers (2)

msgambel
msgambel

Reputation: 7340

You can make the UITableViewController a UIViewController <UITableViewDelegate, UITableViewDataSource>, and then hook it up in a nib with your TabBar. You can find the UITableViewDelegate protocols here. Hope that helps!

Upvotes: 2

jtbandes
jtbandes

Reputation: 118671

The solution will probably be to use a UIViewController instead of a UITableViewController. This way you can have both a UITabBar and a UITableView, both subviews of your view controller's view.

The UITableViewController class reference describes exactly what behavior UITableViewController provides over a plain UIViewController (such as being the delegate and data source, deselecting rows, etc.) — you should implement all this this so everything works as it should.

Upvotes: 2

Related Questions