首页 > 其他 > 详细

UITableView-FDTemplateLayoutCell自动计算UITableView高度的使用

时间:2015-12-09 11:27:31      阅读:151      评论:0      收藏:0      [点我收藏+]

基本应用
如果你有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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!