1. 程式人生 > >iOS 設定 tableView 代理, 註冊 cell, 自適應高度.

iOS 設定 tableView 代理, 註冊 cell, 自適應高度.

// 設定 tableView 代理, 註冊 cell, 自適應高度.

+(void)tableViewRegister:(UITableView *)tableView  identifier:(NSString *)identifier delegate:(id)delegate {

    tableView.estimatedRowHeight = 50.0f;

    tableView.rowHeight = UITableViewAutomaticDimension;

// identifier cell 類檔名相同

    [tableView registerNib:[

UINibnibWithNibName:identifier bundle:[NSBundlemainBundle]] forCellReuseIdentifier:identifier];

    tableView.delegate = delegate;

    tableView.dataSource = delegate;

}