开发者

UITableViewCell is transparent when not supposed to be

My UITableViewCell is being transparent when it's not supposed to be. My ta开发者_StackOverflow中文版ble view has a background color and it shows through the table cell, even though they're supposed to be opaque. I'm not sure why this is.

Relevant code:

    UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:emptyIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:emptyIdentifier] autorelease];
    }

    cell.textLabel.text = @"Empty";
    cell.textLabel.textAlignment = UITextAlignmentCenter;
    cell.textLabel.backgroundColor = [UIColor whiteColor];
    return cell;


I believe it's because of the CGRectZero. Try using initWithStyle and use one of the system styles. http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITableViewCell_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableViewCell/initWithStyle:reuseIdentifier:

Nevertheless, initWithFrame is already deprecated.


in IB, click on the uitableviewcell, then check the "clip subviews" property.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜