Cell 高度缓存
2017-03-12 本文已影响26人
大美象
id model = self.photos[indexPath.row];
ShopPhotoPostModel *postModel = (ShopPhotoPostModel *)model;
if (postModel.cellHeight) {
return postModel.cellHeight;
}
ShopPhotoPostModel *feed = [self.photos objectAtIndex:indexPath.row];
static SceneFeedCell *cell = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
cell = [self.sceceFeedView.tableView dequeueReusableCellWithIdentifier:SceneFeedIdentifierCell];
});
cell.entity = feed;
[cell updateConstraints];
CGSize size = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
feed.cellHeight = size.height + 1.0f;
return size.height + 1.0f;