views:

631

answers:

1

As a follow up to: http://stackoverflow.com/questions/1971165/uilabel-subview-in-uitableviewcell-isnt-showing-up-iphone-dev

I have found out that the UILabel I added as a subview is showing up and positioned correctly, however when I set the cell's labelField, it seems to "overlap" the label I have added in the subview.

In other words "bar" only shows up when I comment out the first line of the following code snippet:


cell.textLabel.text = @"foo"
// sub view text label
UILabel *valueField = (UILabel *)[cell viewWithTag:111];
valueField.text = @"bar";

Is there a way to make the cell.textLabel not overlap the UILabel that's on the "same line"? maybe by adjusting the underlying frame of cell.textLabel?

This problem also seems to only occur when I'm compiling with an SDK > 2.2.1, did something change that would affect this in 3.0?

Thanks

A: 

UITableViewCell´s textLabel has a non clear background. I think that the position from your custom label to this one is so tiny that when the default textLabel shows text, it´s background covers your custom label (bar).

Change the background color for the default textLabel field in this message:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    [cell setBackgroundColor:[UIColor clearColor]];
}
Rigo Vides