自定义UITableViewCell
有三种方式自定义单元格: XIB Storyboard 代码 注意: 通过XIB或者Storyboard自定义单元格时,需要指定单元格的可重用标示符 如果使用XIB方式,需要在viewDidload方法中,注册XIB文件 UINib
*nib = [UINib nibWithNibName:@”bookCell" bundle:[NSBundle mainBundle]]; [self.tableView registerNib:nib forCellReuseIdentifier:@”cell"];

 

UITableView性能优化补充

1. 在Storyboard中直接自定义单元格会注册单元格原型
2. 用XIB方式自定义单元格需要注册NIB
UINib *nib = [UINib nibWithNibName:@”bookCell" bundle:[NSBundle mainBundle]];
[tableView registerNib:nib forCellReuseIdentifier:@”cell"];
3. 用代码方式自定义单元格需要注册类
[tableView registerClass:[MyCell class] forCellReuseIdentifier:CellIdentifier];

以下方法的目的就是要求必须要注册自定义单元格类
[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

 

posted on 2015-02-08 14:51  HJiang  阅读(246)  评论(0编辑  收藏  举报