Search code examples
iosuitableviewuinavigationcontrolleruitabbar

iOS: Which approach to take - x number of dynamic UITableViews


I'm trying to figure out the best approach to take in my current situation. I have an app with a navigation bar controller that at one point needs to present/show x number of table views.(x meaning that the number is decided by communicating with a server)... The table views will each represent e.g a class or a group... (this could be school classes or kindergarden classes) Okay... So... Only one table view should be visible/in focus, but the others should be accessible from the same view...

E.g. The view is presented. A table view for class A is shown. The user can swipe to get class B

I've been considering different approaches, but I can't figure out the best approach to this...

  1. I considered using a scroll view containing the x table views, where only one was visible at a time, and the others could be scrolled in view... But, after doing some research, it seems that Apple recommends that you shouldn't place table views in scroll views, because the scrolling can interfere with each other..
  2. Using a tab bar... Again, my research told me that the navigation bar should be placed in the tab bar, and not the other way around... And I only want a tab bar on this view, and not earlier in the app..
  3. Use a custom tab bar that better supports my "needs"...

Any ideas??


Solution

  • In my opinion the most important thing is that only one UITableView have to be visible. The best solution (ie the simplest) is a first UITableView with its UITableviewController that lists all the classes/categories A,B,.. retrieved from the server, and a secondary UITableView (ie controller /+ tableView) that will display the detailed list for a given class of items. You may also continue to drill down your data tree other sub-tableViews.

    I recommend to use a UINavigationController to push/pop your tableViews when a cell is selected.

    Stacking several UITableViews in a unique container view seems too much complicated and may lead to tricky and/or unwanted states.