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

前端之家收集整理的这篇文章主要介绍了ios – UITableViewCell子视图在选择时消失(但此子视图中的内容可见)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的UITableViewCell的.m文件.
  1. #import "ContentCardTableViewCell.h"
  2. #import <QuartzCore/QuartzCore.h>
  3.  
  4. @implementation ContentCardTableViewCell
  5.  
  6.  
  7. - (void)awakeFromNib {
  8. // Initialization code
  9. [self setBackgroundColor:[UIColor clearColor]];
  10.  
  11. }
  12.  
  13. - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
  14. [super setHighlighted:highlighted animated:animated];
  15. if (highlighted) {
  16. [self setBackgroundColor:[UIColor clearColor]];
  17.  
  18. // Recover backgroundColor of subviews.
  19. }
  20. }
  21.  
  22. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  23. [super setSelected:selected animated:animated];
  24. if (selected) {
  25. [self setBackgroundColor:[UIColor clearColor]];
  26.  
  27. // Recover backgroundColor of subviews.
  28. }
  29. }
  30.  
  31.  
  32. @end

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

解决方法

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

在里面

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


[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

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

猜你在找的iOS相关文章