UITableView inside UITableView?
Usually:
Can I add UITableView
another as a subheading UITableView
? Or should I create UIView
and add each one to it UITableView
?
In particular:
For a ComposeTableViewController
with typeahead, like in the iPhone native mail app, which approach would you recommend and why?
Note. I prefer to build things 100% programmatically (no Builder interface).
-
Subclass
UITableViewController
.Then, to show the results of the typeahead, create and add
resultsTableView
as a subsetself.tableView
, just below the cell (self.tableView
) with the typeahead text box.The best part about this approach is that it
resultsTableView
automatically scrolls withself.tableView
.But, is it okay to add
UITableView
another as a subqueryUITableView
? -
Subclass
UIViewController
.Create and add
tableView
(custom property) as a subsetself.view
.Create and add
resultsTableView
also as a subsetself.view
.The annoying thing about this approach is that I have to manually move around
resultsTableView
manually at any timeself.tableView
.
I think I would prefer approach 1, but adding UITableView
another as a subheading UITableView
seems to me to be smelly.
source to share
TableViews cannot have subviews. You can try adding the table view as a TableViewCell, but then you have to ask yourself how will it scroll, if you tried scrolling in a subtableview, will it scroll through the child table view or the parent table view? It is much easier to represent multiple table views in a view. This can be done easily by setting your custom view manager as the data source of both table views contained in its view and then compare the table pointer that is sent as a data source method parameter to the two table view pointers that are the IVars of your custom view controller ...
source to share
Keep things in a container. Create a container view controller that is of typeahead. This container view controller will hold your main table view controller (and its table view) and it will hold the type's view controller (and its view).
It will keep the logic needed for the typeahead from your main table view, and as a bonus you can get a reusable head-type container that can be applied to other views.
source to share
Yes, it is useful to add UITableView
another as a cell UITableView
.
I had one problem and posted a question
And the requirement was like a group of controls with a list of other controls. I thought it would be messy time if I was going to add UITableView
as a cell UITableView
.
What have I found ... Boy! it's like iOS. There is no delay during this.
Tested for the following features:
- Scrolls like enchantments
- Separate delegates called for each
- Reordering as a
UITableView
cell - Swipe and delete the cell
- Updating duntasource data for both
UITableView
and reloading at the same time.
There is no reason not to add a subview UITableView
.
source to share