iOS 8.1 UITableview背景颜色始终为白色

所以我在iOS 7.1中对它进行了测试,它运行正常.我正在使用下面的行设置背景颜色以清除我的tableview.
self.tableview = [[UITableView alloc]initWithFrame:self.bounds style:UITableViewStylePlain];
    self.tableview.delegate = self;
    self.tableview.dataSource = self;
    self.tableview.backgroundView = nil;
    self.tableview.backgroundColor = [UIColor clearColor];
    self.tableview.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
    [self addSubview:self.tableview];

我还将tableFooterView设置为一个新视图,以隐藏任何剩余未使用的单元格.

self.tableview.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];

这在iOS 7上运行得非常好,但在iOS 8中,我在桌面视图下留下了白色背景颜色. tableview坐在里面的superview也有一个清晰的背景颜色.有任何想法吗?

下面添加图片 – 我不得不模糊客户名称

在iOS 7上工作

不适用于iOS 8.1

解决方法

Apple文件

…在iOS 7中,单元格认为白色背景;在早期版本的iOS中,单元格继承封闭表视图的背景颜色.如果要更改单元格的背景颜色,请在表视图委托的tableView:willdisplayCell:forRowAtIndexPath:方法中执行此操作.

您可能需要使用willdisplayCell UITableView委托方法为表视图提供透明背景.

- (void)tableView:(UITableView *)tableView willdisplayCell:(UITableViewCell *)cellforRowAtIndexPath:(NSIndexPath *)indexPath

{
      [cell setBackgroundColor:[UIColor clearColor]];
}

相关文章

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