UITableViewCell子视图在选择时消失(但此子视图中的内容可见)

6 iphone objective-c uitableview ios

这是我的UITableViewCell的.m文件.

#import "ContentCardTableViewCell.h"
#import <QuartzCore/QuartzCore.h>

@implementation ContentCardTableViewCell


- (void)awakeFromNib {
    // Initialization code
    [self setBackgroundColor:[UIColor clearColor]];

}

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
    [super setHighlighted:highlighted animated:animated];
    if (highlighted) {
        [self setBackgroundColor:[UIColor clearColor]];

        // Recover backgroundColor of subviews.
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    if (selected) {
        [self setBackgroundColor:[UIColor clearColor]];

        // Recover backgroundColor of subviews.
    }
}


@end
Run Code Online (Sandbox Code Playgroud)

但是这个UITableViewCell中的一个视图在选择时消失了.我曾尝试这个这个,还有更多,但没有任何帮助.有什么我想念的吗?

abh*_*ran 7

我有类似的问题.
如果我将selectionStyle设置为UITableViewCellSelectionStyleNone工作正常,问题解决了.即;

在里面

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath


[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

在返回牢房之前.希望它有效.