0

I'm creating my first iPad app and I have a UIView which has a table as well as other views. I've noticed I have the option of creating a 'Container View' in which I can then embed a UITableViewContoller.

What are the advantages and disadvantages of embedding a UITableViewContoller rather than just using a UITableView?

Graham Lea
  • 5,797
  • 3
  • 40
  • 55

4 Answers4

2

A UITableViewController adds some subtle (but helpful) functionality that using a UITableView by itself does not have.

Some examples (I don't know if this is a complete list, there may be more):

  • in viewWillAppear, clears and reloads the table automatically
  • In viewWillAppear, it flashes the scroll indicators to indicate the view is scrollable
  • if you have edit fields in your UITableView, it will automatically scroll the table to the appropriate location when the Keyboard is displayed.

Hope that helps!

pdriegen
  • 2,019
  • 1
  • 13
  • 19
1

A UiTableViewController is simply a subclassed UIViewController which has a UITableView as its "view". The benefits of using it are having the boiler plate code written for you and having less setup.

rooster117
  • 5,502
  • 1
  • 21
  • 19
0

Here's a big disadvantage of using a Container View and embedding: it only works on iOS 6+. Trying to run a storyboard with an embedded Container View on iOS 5 results in the error message "Could not instantiate class named UIStoryboardEmbedSegueTemplate"

Graham Lea
  • 5,797
  • 3
  • 40
  • 55
0

UITableViewController is your only option for static/grouped cells.

maksa
  • 374
  • 5
  • 16