UITableViewController

  1. 父类是UIViewController

UITableViewController常用创建方法

// 指定UITableView的style创建控制器
- (instancetype)initWithStyle:(UITableViewStyle)style NS_DESIGNATED_INITIALIZER;

UITableViewController常用属性

  1. 默认会创建tableView,并让其成为自身成员变量,就算把storyboard中的tableView删掉也会运行,只是没法通过storyboard直接设置UITableView和UITableViewCell的属性
    @property (nonatomic, strong, null_resettable) UITableView *tableView;
    
  2. 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.
  1. 造成这个错误的原因
    错误地将一个UIViewController当做UITableViewController来用
  • 错误做法


    UITableViewController_第1张图片
    Snip20151108_134.png
  • 正确做法


    UITableViewController_第2张图片
    Snip20151108_135.png

    UITableViewController_第3张图片
    Snip20151108_137.png

你可能感兴趣的:(UITableViewController)