这些“管道”字符出现在我的桌面视图中的一些单元格中,但仅在iOS 6上出现。第一个屏幕截图显示了iOS 6上的问题,下面的屏幕截图是iOS 4.3:
感谢您提供的任何帮助。
以下是我正在使用的代码:
- (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [NSString stringWithFormat:@"Cell%d%d", indexPath.section, indexPath.row];
UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
UIView *clearColor = [[UIView alloc] init];
clearColor.backgroundColor = [UIColor clearColor];
cell.selectedBackgroundView = clearColor;
}
UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 243.5, 25)];
[label1 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:16.0]];
[label1 setTextColor:[UIColor blackColor]];
label1.text = [[self.tableDataSource objectAtIndex:indexPath.row] objectForKey:@"Name"];
[cell addSubview:label1];
UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(253.5, 10, 243.5, 25)];
[label2 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:16.0]];
[label2 setTextColor:[UIColor blackColor]];
label2.text = [[self.tableDataSource objectAtIndex:indexPath.row] objectForKey:@"Email"];
[cell addSubview:label2];
UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(507, 10, 243.5, 25)];
[label3 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:16.0]];
[label3 setTextColor:[UIColor blackColor]];
label3.text = [[self.tableDataSource objectAtIndex:indexPath.row] objectForKey:@"Phone"];
[cell addSubview:label3];
UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(760.5, 10, 243.5, 25)];
[label4 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:16.0]];
[label4 setTextColor:[UIColor blackColor]];
label4.text = [[self.tableDataSource objectAtIndex:indexPath.row] objectForKey:@"Business"];
[cell addSubview:label4];
return cell;
}
点击查看大图
答案 0 :(得分:1)
原来我必须将每个标签的背景颜色设置为清除:
label.backgroundColor = [UIColor clearColor];
答案 1 :(得分:1)
您使用UILabels的具体原因是什么?我检查了我所拥有的iOS 6应用程序的代码,并使用了NSStrings。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *newTitle = @"my string";
cell.textLabel.text = newTitle;
}
答案 2 :(得分:1)
为标签设置清晰的背景颜色
label.backgroundColor = [UIColor clearColor];