当前位置: 代码迷 >> 综合 >> IOS UITableView 图片文字重叠问题
  详细解决方案

IOS UITableView 图片文字重叠问题

热度:19   发布时间:2023-12-15 02:13:46.0

因为涉及到复用问题,所以可以将其cell.contentView.subviews  的  UIView  remove掉。

然后在初始化cell中的UIView时给其:

  UIImageView *_rightDrivesingImageView = (UIImageView*)[cell.contentViewviewWithTag:1007];


以上两步就可以去掉cell中图片与文字交替使用时,重叠的问题了。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{NSString *strs =nil;staticNSString *CellWithIdentifier =@"Cell";UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:CellWithIdentifier];for (UIView *subViewin cell.contentView.subviews){[subView removeFromSuperview];}if (cell ==nil){cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleValue1reuseIdentifier:CellWithIdentifier];}cell.textLabel.font =cellFont;
}


        else if (indexPath.row == 4){cell.textLabel.text = @"驶证";cell.accessoryType = YES;cell.selectionStyle = UITableViewCellSelectionStyleNone;<span style="color:#ff6666;">  UIImageView *_rightDrivesingImageView = (UIImageView*)[cell.contentView viewWithTag:1007];</span>if ((UIImageView*)[cell.contentView viewWithTag:1007] == nil){_rightDrivesingImageView = [[UIImageView alloc]initWithFrame:CGRectMake(kDEVICEWIDTH - 55, 8, cellImageWidth, cellIimagehight)];_rightDrivesingImageView.tag = 1007;}<span style="color:#ff0000;">UILabel *_tempLabel  = (UILabel *)[cell.contentView viewWithTag:2001];
</span>            if ((UILabel *)[cell.contentView viewWithTag:2001] == nil){_tempLabel = [self generateUploadNameLabel:@""];_tempLabel.tag = 2001;}


  相关解决方案