4

I have a table view with expanding cells for each of them. I want to make every expanding cell be a new table inside of the bigger one. Is that possible? I've done the research, someone said that duplicate UITableView cannot put in one file.

For example

dish order1

=================

dish order2


rice


coke

===============

dish order3

which every "dish order #" is a cell of a table, and when you expand one cell, there will be a smaller table appears. I've done all the expanding stuff. But don't know how to put a small table into a bigger one. Thanks

tracer_rock
  • 165
  • 1
  • 3
  • 9

6 Answers6

5

Well if i understand your question correctly, what you search is called nested tableView, here's some examples:

Good luck.

Vlad Z.
  • 3,401
  • 3
  • 32
  • 60
3

It would likely be impossible to put one table view inside of another table view, and if you did manage to do it, it would be awful. Ask yourself, have you EVER seen this in a commercial app? If not, as a novice iOS developer, you are out of your depth trying to invent new UI paradigms.

Master the existing UI tools first. Don't try to use the UI elements in totally novel ways until you have a strong feel for the standard way to use them. Expect this to take 6 months or more.

Others have suggested a sectioned table view where initially only the first element of a section is visible, but when you tap on it, it expands to add other rows. This works quite well.

Another approach would be to use a master/detail UI, where tapping on one table view cell pushes a new view controller the uses a new table view to display detail information about the previously selected item. There are some use cases where you might have several levels of increasing detail.

Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • yea, but the thing is that if there is only one table, all each cell will randomly get data from different sources. Like dish order number is different from dish order list. – tracer_rock Jan 29 '14 at 17:09
  • @whiack, ok you've got data coming in from different sources. That has no bearing on the idea of trying to nest one view controller inside another. This is a disaster in the making, and a very bad idea. – Duncan C Jan 29 '14 at 22:04
  • @DuncanC -1 why? ...Have you ever developed: LaF, M2M panels, GUI for games or hardware control? not always the default UI, offer the best solution, so open your mind to new ideas. – RTOSkit Aug 26 '14 at 08:35
  • @RTOSkit, for starters, table views use pan gestures to manipulate them. With a table view inside a table view, there's going to be confusion as to where a gesture belongs. Should it go to the inner cell. The inner table view? The outer cell? The outer table view? Not clear. Plus it's going to be visually very cluttered and confusing. I've been in the business for over 30 years, and done a little bit of everything. I stand by my original comment. Bad idea. – Duncan C Aug 29 '14 at 22:33
  • @DuncanC OK, I understand your position. Same here ...20 years in this business, but in your answer seems excessive to me accepting only the default UI solutions because some young people have great ideas, if you make a fake edit in your answer I can remove my negative feedback – RTOSkit Aug 30 '14 at 16:52
  • @RTOSkit, solved? You're not the OP. What problem did you solve? – Duncan C Sep 11 '14 at 00:30
  • @DuncanC :) your feedback is ok now,sometimes it's better to lose battles that I can't partake. You win, OP is down. – RTOSkit Sep 11 '14 at 10:39
1

I really do not think you want two instance of UITableView, instead what you want is a sectioned UITableView which expands when it's header is tapped. Apple has a good sample code for this here:

UITableView expand/collapse

Oscar Gomez
  • 18,436
  • 13
  • 85
  • 118
1

i have demo for you , just got from github..

https://github.com/mitsBhadeshiya/ExpandingCell

i hope this is helpfull for you...

Mitul Bhadeshiya
  • 1,280
  • 1
  • 12
  • 32
0

Have you considered using one UITableView with multiple sections? You can accomplish what you are depicting above with only one tableView.

Matt J
  • 58
  • 5
  • yea, but the sections will be adding as user using it. I don't know if there's a way for dynamically allocating new sections. – tracer_rock Jan 29 '14 at 17:53
-1

Since this was a problem for many people in the past, iOS 9 has a thing called Stack View, it does exactly what you are saying.

Check out this article.

jairobjunior
  • 473
  • 5
  • 11
  • StackView is used for a different purpose. A StackView doesn't have a TableSource like thing to hold the rows for the main view. – Rizan Zaky Mar 27 '18 at 05:57