2

I need to add a new table view to my UITableViewController which will includes a different data and design.

enter image description here

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: enter image description here

5
  • You need to develop different kind of cells in one TableView am I right? Commented May 10, 2013 at 11:26
  • no i need to develop another table view (list of new contents). Commented May 10, 2013 at 11:27
  • can you attach some examples of design that you need in the end Commented May 10, 2013 at 11:27
  • Different content but cells design will be the same, am I right? Commented May 10, 2013 at 11:28
  • the fast news is a table view which includes different data to the the below table view which is sectioned viewed Commented May 10, 2013 at 11:35

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

how can I rely a UITableViewController to UIViewController as subviews?
Just instantiate them and add them as subviews, something like: MyTableViewController *tableVC = [[MyTableViewController alloc] init]; [self.view addSubview:tableVC.tableView]; This might require some frame adjusting, but it should work (MyTableVC is your tableViewController class that you made yourself).
0

I think you should use UIExpandableTableView

there is detailed usage on github page

Example of UIExpandableTableView

Scree example of UIExpandableTableView

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.