解决cell重用

来源:互联网 发布:淘宝网羽绒服半成品 编辑:程序博客网 时间:2024/05/21 05:36

方法一:

//解决侧拉栏重用问题关键  (每次重绘cell 移除旧的)

//    [[cell.contentView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview) withObject:nil];


方法二: 

 //换成这句防止cell的重用

 NSString *cellIdentifier = [NSString stringWithFormat:@"%ld_%ld", (long)indexPath.section, (long)indexPath.row];


方法三: 

将控件置空   

例如: 

        cell.typeLabel1.text = nil;

        cell.typeLabel1.layer.backgroundColor = nil;

        cell.typeLabel1.layer.borderColor = nil;

        cell.typeLabel1.layer.borderWidth = 0;

        cell.contentLabel1 =nil;

        cell.lineView.backgroundColor = nil;

        cell.citylabel1.text = nil;

        cell.areaLabel1.text = nil;

        [cell.commentBtu1 setBackgroundImage:nil forState:UIControlStateNormal];

        [cell.likeBtu1 setBackgroundImage:nil forState:UIControlStateNormal];

0 0