问题
What all does UITableViewController
get me that makes it actually useful? Is there any bonus is using it instead of just using a UIViewController
for views with UITableViews
in them? I ask because I want my views with UITableViews
to inherit from a base view controller (which inherits from UIViewController
). If I use a UITableViewController
then having a base class for all my views becomes more difficult.
回答1:
Not much. It provides some conveniences, but you never really need it; I often don't use it.
The main things, aside from the automatic setup when you create one in the storyboard, are the three properties tableView
, clearsSelectionOnViewWillAppear
, and refreshControl
. But they don't do anything you can't do yourself.
回答2:
Well I do think both Retro and matt's answer are correct, from personal experience it is much easier and less "hackY" to use UITableViewController
with UIRefreshControl
, then trying to get UIRefreshControl work with UIViewController with a UITableView.
回答3:
Nothing more then the boilerplate code ready for setting the data source and connection to your tableView object, some getters and setter to make your life easy if you not want to put your effort to do the same thing which is available.
But in your case for SubClass its not fit to have UItableViewController
来源:https://stackoverflow.com/questions/21200297/uitableviewcontroller-vs-uiviewcontroller