【发布时间】:2014-01-31 04:49:03
【问题描述】:
好吧,也许我太挑剔了。如果您看不到它,请提前道歉,但在第二张图片中,该行上的项目有点像素化,或者好像一个词被放在了一个词的顶部。这仅在我向上滚动 tableview 后发生,否则,它类似于第一张图像。
第一张照片:
第二张图(你可以在这里看到字体的不同):
当我向上滚动时,它会更加大胆和不精致。
坦率地说,我不知道为什么。表视图正在正常加载。任何帮助、预感或建议都会密切相关,即使它可以将我指向正确的区域。
这是第二张图片的表格视图的代码。
static NSString *CellIdentifier = @"OrderProductCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
//cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
//configure cell, display name and cost of each item
OrderProduct *p = [[order.items allObjects] objectAtIndex:indexPath.row];
UILabel *lableName=[[UILabel alloc]initWithFrame:CGRectMake(10, 16, 300, 20)];
lableName.backgroundColor=[UIColor clearColor];
lableName.font=[UIFont boldSystemFontOfSize:19];
[lableName setFont:[UIFont fontWithName:@"Arial-Bold" size:12.0]];
lableName.text=p.name;
//UILabel *counterNumber=[[UILabel alloc]initWithFrame:CGRectMake(10, 25, 300, 20)];
//counterNumber.backgroundColor=[UIColor clearColor];
//counterNumber.font=[UIFont systemFontOfSize:12];
//counterNumber.text=[NSString stringWithFormat:@"Scan time :%@",p.scannerCounter];
[cell.detailTextLabel setText:[NSString stringWithFormat:@"%@ %.02f",p.currency, p.cost]];
cell.imageView.image = [UIImage imageNamed:p.image];
[cell addSubview:lableName];
//[cell release];
//[cell addSubview:counterNumber];
return cell;
【问题讨论】:
-
显示
cellForRowAtIndexPath方法的代码。 -
不要直接给cell添加label,添加到cell的contentView中
-
您的代码也会导致问题,同时重用单元格。重复使用单元格时,需要先移除现有标签,然后添加新标签。
标签: ios uitableview label uilabel tableview