代碼獲取使用XIB形成的視圖
//從mainBundle包中加載同名的試圖控制器文件篱竭,默認(rèn)加載的是RootViewController.nib文件參數(shù)可以寫nil
RootViewController *rootVC = [[RootViewController alloc]initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]];
//如果使用XIB繪制cell的話诽偷,一定要注意表視圖必須注冊(cè)cell類
[self.tableView registerNib:[UINib nibWithNibName:@"MyTableViewCell"bundle:[NSBundle mainBundle]]forCellReuseIdentifier:kStr];
自定義高度
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 800;//最大高度葫掉;
//并且在創(chuàng)建cell的方法中不需要重新創(chuàng)建cell
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
StudentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kReuse forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell sendValueByStudent:_dataArray[indexPath.row]];
Treturn cell;
}