Skip to content

shunFSKi/FSAutoAdjust-cellHeightDemo

Repository files navigation

FSAutoAdjust-cellHeightDemo

badge-languages CocoaPods CocoaPods CocoaPods CocoaPods

cell行高自适应,一句代码搞定需求,丝滑般顺畅的滚动体验

API

支持两种缓存方式

/**
 cell自动计算行高

 @param tableView tableView
 @param indexPath indexPath
 @param contentViewWidth cell内容宽度,不确定可传0
 @return cell高度
 */
+ (CGFloat)FSCellHeightForTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath cellContentViewWidth:(CGFloat)contentViewWidth bottomOffset:(CGFloat)bottomOffset;
/**
 cell自动计算行高优化版

 @param tableView tableView
 @param indexPath indexPath
 @param cacheKey 当前cell唯一标识符
 @param contentViewWidth cell内容宽度,不确定可传0
 @return cell高度
 */
+ (CGFloat)FSCellHeightForTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath cacheKey:(NSString *)cacheKey cellContentViewWidth:(CGFloat)contentViewWidth bottomOffset:(CGFloat)bottomOffset;

How To Use

1、将demo中的FSAutoAdjust-cellHeightLib拖入项目中导入#import "UITableViewCell+FSAutoCountHeight.h"

2、cocoapods:pod search FSAutoAdjust-cellHeight 如果找不到执行pod setuppod 'FSAutoAdjust-cellHeight'

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    FSEntity *entity = _datas[indexPath.row];
    CGFloat height = [self.title isEqualToString:@"keyCache"]?[FSTestTableViewCell FSCellHeightForTableView:tableView indexPath:indexPath cacheKey:entity.identifier cellContentViewWidth:0 bottomOffset:0]:[FSTestTableViewCell FSCellHeightForTableView:tableView indexPath:indexPath cellContentViewWidth:0 bottomOffset:0];
    return height;
}

详细请下载demo查看

Document

文档正在努力编写中。。。

文章地址:http://www.jianshu.com/p/16a67c58c8c4

Version

1.0.2 ——>添加cocoapods支持 2017.8.7

About

cell行高自适应,一句代码搞定需求,丝滑般顺畅的滚动体验

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published