开发者

UITableViewCell's textLabel is overlapping a subview label, how can I fix it? (iPhone Dev)

As a follow up to: UILabel subview in UITableViewC开发者_开发百科ell isn't 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


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]];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜