klcjr89
klcjr89

Reputation: 5902

Weird tableViewCell issue on iOS 6

These "pipe" characters are appearing in some of my cells on my table view, but only on iOS 6. The first screenshot shows the issue on iOS 6, and the lower screenshot is iOS 4.3:

I appreciate any help offered.

Here is the code I'm using:

- (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;
}

click for larger image

enter image description here

enter image description here

Upvotes: 0

Views: 342

Answers (3)

mano
mano

Reputation: 184

set clear background colour for labels

label.backgroundColor = [UIColor clearColor];

Upvotes: 1

klcjr89
klcjr89

Reputation: 5902

Turns out I had to set each label's background color to clear:

label.backgroundColor = [UIColor clearColor];

Upvotes: 1

MaxPower
MaxPower

Reputation: 63

Any specific reason you're using UILabels? I checked the code for an iOS6 application I have and I used NSStrings.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
  NSString *newTitle = @"my string";
  cell.textLabel.text = newTitle;
}

Upvotes: 1

Related Questions