- 父類是UIViewController
UITableViewController常用創建方法
// 指定UITableView的style創建控制器
- (instancetype)initWithStyle:(UITableViewStyle)style NS_DESIGNATED_INITIALIZER;
UITableViewController常用屬性
- 默認會創建tableView,并讓其成為自身成員變量,就算把storyboard中的tableView刪掉也會運行,只是沒法通過storyboard直接設置UITableView和UITableViewCell的屬性
@property (nonatomic, strong, null_resettable) UITableView *tableView;
- UITableViewController中的View即tableView,可通過打印地址檢驗
tableViewController.view == tableViewController.tableView
UITableViewController常用方法
- 默認遵守了UITableView數據源協議,UITableViewDelegate協議,是UITableView的代理
- 詳見UITableView
UITableViewController使用過程中,可能會出現的錯誤
- [UITableViewController loadView] instantiated view controller with identifier "UIViewController-BYZ-38-t0r" from storyboard "Main", but didn't get a UITableView.
- 造成這個錯誤的原因
錯誤地將一個UIViewController當做UITableViewController來用
-
錯誤做法
Snip20151108_134.png
-
正確做法
Snip20151108_135.png
Snip20151108_137.png