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 subset self.tableView

    , just below the cell ( self.tableView

    ) with the typeahead text box.

    The best part about this approach is that it resultsTableView

    automatically scrolls with self.tableView

    .

    But, is it okay to add UITableView

    another as a subquery UITableView

    ?

  • Subclass UIViewController

    .

    Create and add tableView

    (custom property) as a subset self.view

    .

    Create and add resultsTableView

    also as a subset self.view

    .

    The annoying thing about this approach is that I have to manually move around resultsTableView

    manually at any time self.tableView

    .

I think I would prefer approach 1, but adding UITableView

another as a subheading UITableView

seems to me to be smelly.

+3


source to share


4 answers


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 ...



+1


source


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.

0


source


Yes, it is useful to add UITableView

another as a cell UITableView

.

I had one problem and posted a question

Multiple subzone views

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

.

0


source


You can do this, but it is against the MVC principle. You will set the view delegate to a different view which is wrong.

0


source







All Articles