美文网首页
Cell 高度缓存

Cell 高度缓存

作者: 大美象 | 来源:发表于2017-03-12 16:46 被阅读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;

相关文章

网友评论

      本文标题:Cell 高度缓存

      本文链接:https://www.haomeiwen.com/subject/ajtxnttx.html