Reputation: 527
I need to add a new table view to my UITableViewController which will includes a different data and design.
the above prototype cells is the new table view I've added in storyboard, and the main table view is the second one which includes (title, label, and image).
Is it allowed to create another table view in UITableViewController, or should I create a UIViewController and implement the two tables in it???
In fact, I've finished the implementation of the first table view controller, so I need to implement the new one.
the attached image is showing what I want:
Upvotes: 2
Views: 502
Reputation: 96
Are you looking to have them be two independent tables, or is it a master/child setup? If they are independent, I suggestion using one table and two sections, then depending on the section number return to correct cell. For master/child, think about making a view that looks like a cell and have the master cells be the sections views and the children be the actually rows. You can make a section class that stores if the children are visible or not and in the numberOfRowsInSection method return the count if visible or 0 if not.
Just a couple ideas
Upvotes: 0
Reputation: 345
I think you should use UIExpandableTableView
there is detailed usage on github page
Scree example of UIExpandableTableView
Upvotes: 0
Reputation: 4552
You will be better off with a UIViewController
that has two tableViews
as subviews if you want both of your tables to be shown at the same time. UITableViewController
should be used only when there is just one tableView shown at a certain time.
You can either have one UIViewController
being the dataSource
and delegate
for both of the tableViews, or have a UITableViewController
for each of your tables and add them as subviews to a UIViewController
that will be a container view for both of them. The latter will probably save you some time debugging possible issues as having two tableViews with a single delegate
/dataSource
requires a lot of duplicate code in the same place.
Upvotes: 1