2

该声明:

[tableView setBackgroundColor:[UIColor clearColor]];

no effect only on iPad especially with iOS8 with my existing App only。只是为了测试一下,我创建了一个新的测试应用程序只是为了查明问题但是it works。我创建了一个这样的UIViewController类:

@implementation TestViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self.view setBackgroundColor:[UIColor purpleColor]];

    UITableView *aTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 100, 300, 300) style:UITableViewStylePlain];

    [aTableView setBackgroundColor:[UIColor clearColor]];

    [self.view addSubview:aTableView];
}

@end

并使用以下语句推送 ist:

[self.navigationController pushViewController:[TestViewController new] animated:YES];

从这样的新测试应用结果推送(如我所愿):

在此处输入图像描述

但从我现有的应用程序(我必须实现的真正应用程序)结果如下:

在此处输入图像描述

即使在 iOS 8 iPhone 下,清除背景颜色在 iOS7 iPhone 和 iPad 下也能完美运行。我试图找到可以影响外观的 UIAppearance 代理实现,但没有。

我已经尝试了几个 SO 建议,包括setting the backgroundView to nilthey haven't helped

为什么它可以与新的测试应用程序一起使用,为什么它不能与我的现有应用程序一起使用?有什么关系UINavigationController吗?

注意:请不要标记为重复,因为这里的问题与现有问题完全或略有不同。

4

2 回答 2

3

这是细胞的颜色。所以你必须改变你的细胞的颜色。有关更多信息,请参阅

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    cell.backgroundColor = [UIColor clearColor];
}
于 2014-10-28T07:28:37.570 回答
0
UIView *bgView = [[UIView alloc] initWithFrame:cell.frame];
bgView.backgroundColor = [UIColor clearColor];
cell.backgroundView = bgView;

Try the above code

于 2014-10-28T07:41:11.363 回答