Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SwiftHsw opened this issue Dec 19, 2018 · 0 comments

Comments

@SwiftHsw
Copy link

  • (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; // 取消固定高度约束
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant