GSD_WeiXin icon indicating copy to clipboard operation
GSD_WeiXin copied to clipboard

朋友圈数据多 卡顿,setModel里面一直滚动重用赋值,导致卡顿,有没有办法优化

Open SwiftHsw opened this issue 6 years ago • 0 comments

  • (void)setupWithLikeItemsArray:(NSArray *)likeItemsArray commentItemsArray:(NSArray *)commentItemsArray { self.likeItemsArray = likeItemsArray; self.commentItemsArray = commentItemsArray;

    if (self.commentLabelsArray.count) { [self.commentLabelsArray enumerateObjectsUsingBlock:^(UILabel *label, NSUInteger idx, BOOL *stop) { [label sd_clearAutoLayoutSettings]; label.hidden = YES; //重用时先隐藏所以评论label,然后根据评论个数显示label }]; }

    if (!commentItemsArray.count && !likeItemsArray.count) { self.fixedWidth = @(0); // 如果没有评论或者点赞,设置commentview的固定宽度为0(设置了fixedWith的控件将不再在自动布局过程中调整宽度) self.fixedHeight = @(0); // 如果没有评论或者点赞,设置commentview的固定高度为0(设置了fixedHeight的控件将不再在自动布局过程中调整高度) return; } else { self.fixedHeight = nil; // 取消固定宽度约束 self.fixedWidth = nil; // 取消固定高度约束 }

SwiftHsw avatar Dec 19 '18 02:12 SwiftHsw