UITableViewCell show white background and cannot be modified on iOS7

后端 未结 14 1331
轻奢々
轻奢々 2020-11-28 18:42

I\'ve implemented a custom table view cell class that inherit from UITableViewCell. The tableview contains a background image, so I want cell\'s background to b

14条回答
  •  时光取名叫无心
    2020-11-28 19:08

    It could be that your UITableViewCell is selected by default.. You can confirm this using Xcode 6s new visual debugger (or find out exactly which view is causing this white cell to appear).

    enter image description here

    Interestingly, after knowing this.. setting the background color of the selected cell to clear still didn't work.. doing some more research, turns out i just had to modify the selection style when i'm creating this custom cell:

    - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        if (self) {
            // do customization here
        }
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setBackgroundColor:[UIColor clearColor]];
        return self;
    }
    

提交回复
热议问题