I’m trying to get a GUI with a UITabBar and UITableViews set up.
I’ve got a UITabView that is programmatically created.
One of the Tabs displays a UITableView that is also programmatically created.
This UITableView then displays other views when didSelectRowAtIndexPath is called.
Unfortunately, when a table cell is clicked, my tab view goes away and the new table view is displayed.
What I can’t get my head around is how to structure the views so that the tabBar stays on the screen.
Is it as simple as making the UITableViews shorter, or is there some window/view mojo that I’m missing?
Thanks
You should use a UITabBarController to display the UITabBar rather than doing it directly.
Then use a UITableViewController as the view controller for a given tab. Though I get the impression that you want to present descendent UITableViews when a row is selected. If this is the case, you ought to use a UINavigationController as the tab bar’s view controller, and let it manage your UITableViewControllers.
Remember that on iOS you really need to use the view controller pattern – the frameworks take care of a lot of things for you under the hood.
Follow-up:
OK, the following straightforward implementation works just fine for me. Please ignore the many obvious issues with this code (beginning with the fact that I hacked it all together in the application delegate!); it’s intended purely as a model for how your controllers should be glued together.