标签:
基本应用
如果你有self-satisfied cell,那么你应该做的是:
#import "UITableView+FDTemplateLayoutCell.h"
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [tableView fd_heightForCellWithIdentifier:@"reuse identifer" configuration:^(id cell) {
// Configure this cell with data, same as what you‘ve done in "-tableView:cellForRowAtIndexPath:"
// Like:
// cell.model = self.datas[index.row];
}];
}
进阶应用(iOS7下也能用)
Since iOS8, -tableView:heightForRowAtIndexPath: will be called more times than we expect, we can feel these extra calculations when scrolling. So we provide another extension with caches:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [tableView fd_heightForCellWithIdentifier:@"identifer" cacheByIndexPath:indexPath configuration:^(id cell) {
// configurations
}];
}
UITableView-FDTemplateLayoutCell自动计算UITableView高度的使用
标签:
原文地址:http://www.cnblogs.com/Rinpe/p/5032154.html