如要查看完整代码,请移步仿煎蛋github
1、UITableView数据绑定的简化
[CETableViewBindingHelper bindingHelperForTableView:self.tableView
sourceSignal:sourceSignal selectionCommand:command customCellClass:[FreshNewsCell class]];
当然了这句代码有点长,因为他解决了四个问题(对应四个参数):
- self.tableView 绑定的tableView
- soureSignal 带有列表数据的信号
- command cell的点击事件
- [FreshNewsCell class] 自定义的cell
补充: 如果不想自定义cell,使用系统自带的cell,可以调用如下方法:
[CETableViewBindingHelper bindingHelperForTableView:self.tableView sourceSignal:RACObserve(self, menuArray)
selectionCommand:menuCommand templateCellClass:[LeftMenuCell class]];
2、性能优化
- 异步加载图片,使用SDWebImage
- 在cellForRowAtIndexPath方法中只赋值,计算放在模型中
- 提前计算好cell高度,或者进行缓存
- 设置阴影时,一定要设置shadowPath,或者使用图片
- cell中的view ,设置为opaque
- 使用quarz2d, 异步绘制复杂的cell布局