UITableview cell上的数据或控件覆盖问题。

来源:互联网 发布:java new object 赋值 编辑:程序博客网 时间:2024/06/04 21:38
static NSString *identifier = @"Fanmeli";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
//cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:identifier];
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }else{
        // 删除cell中的子对象,解决覆盖问题。
        while ([cell.contentView.subviews lastObject] != nil) {
            [(UIView*)[cell.contentView.subviews lastObject] removeFromSuperview];
        }
    }

原创粉丝点击