开发者

Why is there a background on a table cell's text, but only on the iPad?

I'm trying开发者_运维知识库 to set the background color on a cell. It works fine in iOS 4 on a 3GS and in the sim, but when I test in 3.2 I get a background on the text label that I can't get rid of.

Why is there a background on a table cell's text, but only on the iPad?

I've tried to set the opacity and background of the label, detail label, content view, and accessory views manually and had no success. I even resorted to the following to make sure I "got everything" (though I don't know what else there would be...).

void setBackgroundColor (UIView *view, UIColor *color) {
    view.opaque = NO;
    view.backgroundColor = color;
    for (UIView *subview in [view subviews]) {
        setBackgroundColor(subview, color);
    }
}
...
setBackgroundColor(cell, [UIColor blueColor]);

So, what could cause this on the iPad but not on the iPhone?


It turns out that you can't set the background in cellForIndexPath and have to do it in:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

Now it works perfectly.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜