简体   繁体   中英

UITableViewController vs UIViewController

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.

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.

好吧我觉得Retro和matt的答案都是正确的,从个人经验来看,使用UITableViewControllerUIRefreshControl会更容易,更少“hackY”,然后试图让UIRefreshControl与UITableController一起使用UITableView。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM