当Scroll UITableView它与iOS名称重叠时

Div*_*iya -1 objective-c alasset alassetslibrary uicollectionview ios7

当我滚动tableview时会给出这种类型的重叠 在此输入图像描述

我在CellForRow AtIndexPath方法中编写下面的代码,我以编程方式创建tableview ...

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
}

NSDictionary *info = [ASSETHELPER getGroupInfo:_groupArray[indexPath.row]];
UIImageView *view;

if (indexPath.row % 2) {
    view=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"dark_bg"]];
}else{
    view=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"light_bg"]];
}
cell.backgroundView=view;

UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 50, 50)];
imgView.backgroundColor=[UIColor clearColor];
[imgView.layer setCornerRadius:25];
[imgView.layer setMasksToBounds:YES];
[imgView.layer setBorderColor:[UIColor whiteColor].CGColor];
[imgView setImage:[info objectForKey:@"thumbnail"]];
[cell.contentView addSubview:imgView];

UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(80, 20, 200, 30)];

[label setText:[info objectForKey:@"name"]];
[cell.contentView addSubview:label];

return cell;
Run Code Online (Sandbox Code Playgroud)

}

小智 8

试试这段代码.您使用了dequeueReusableCellWithIdentifier:

NSString *CellIdentifier = [NSString stringWithFormat:@"Cell %d",indexPath.row];

UITableViewCell *cell=[self.tableView cellForRowAtIndexPath:indexPath];

if (cell == nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Run Code Online (Sandbox Code Playgroud)