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

这是我的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

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

解决方法

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

在里面

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


[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

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

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...