cell for ui repeat

if ([[LoginInfoModel sharedInstance].uid isEqualToString:statusFrame.status.feed_user_id]) {
        _focusButton2.hidden = YES;
    }else{
        if ([statusFrame.status.subscribeStatus integerValue] ==0) {
            [_focusButton2 setTitle:@"+关注" forState:UIControlStateNormal];
            [_focusButton2 setTitleColor:[JJTool colorWithHexValue:0xf04c4d] forState:UIControlStateNormal];
            _focusButton2.hidden = NO;
        }else{
            if ([self.flagVC isEqualToString:@"关注"]) {
                _focusButton2.hidden = YES;
            }else{
                if ([_focusButton2.titleLabel.text isEqualToString:@"+关注"]) {
                    _focusButton2.hidden = NO;
                    [_focusButton2 setTitle:@"已关注" forState:UIControlStateNormal];
                    [_focusButton2 setTitleColor:[JJTool colorWithHexValue:0xaaaaaa] forState:UIControlStateNormal];
                }else{
                    _focusButton2.hidden = YES;
                }
            }   
        }
    }
   if ([_focusButton2.titleLabel.text isEqualToString:@"+关注"]) {

这种方式的判断会有如下效果,我觉得正确方式是对每个cell对应的model赋对应的值才可以,否则会因为循环利用出现UI重复显示!本来“已关注”已隐藏,但是向上滑动的时候又显示了出来。
处理方式给model添加属性作标识:statusFrame.flagfirstFocus,效果okay

if ([self.flagVC isEqualToString:@"关注"]) {
                _focusButton2.hidden = YES;
            }else{
                if ([statusFrame.flagfirstFocus isEqualToString:@"flagfirstFocus"]) {
                    _focusButton2.hidden = NO;
                    [_focusButton2 setTitle:@"已关注" forState:UIControlStateNormal];
                    [_focusButton2 setTitleColor:[JJTool colorWithHexValue:0xaaaaaa] forState:UIControlStateNormal];
                }else{
                    _focusButton2.hidden = YES;
                }
            }
cell for ui repeat_第1张图片
1.pic.jpg
cell for ui repeat_第2张图片
2.pic.jpg

你可能感兴趣的:(cell for ui repeat)