您的位置:首页 > 产品设计 > UI/UE

IOS UITableView 图片文字重叠问题

2015-08-17 20:51 555 查看
因为涉及到复用问题,所以可以将其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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: