【问题标题】:[tableView setBackgroundColor:[UIColor clearColor]] is not working only on iPad with iOS8[tableView setBackgroundColor:[UIColor clearColor]] 仅适用于 iOS8 的 iPad
【发布时间】:2014-10-28 07:14:50
【问题描述】:

声明:

[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];

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

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

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

我已经尝试了每个 SO 提案,包括 setting the backgroundView to nilthey haven't helped

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

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

【问题讨论】:

    标签: ios iphone ipad uitableview uibackgroundcolor


    【解决方案1】:

    这是单元格的颜色。所以你必须改变你的细胞的颜色。欲了解更多信息,请参阅

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
    {
        cell.backgroundColor = [UIColor clearColor];
    }
    

    【讨论】:

    • 我已经尝试过您的建议,我也刚刚再次尝试,但没有任何变化。请注意,上面提到的(我的代码)适用于一个应用程序,而不适用于另一个应用程序。谢谢
    【解决方案2】:
    UIView *bgView = [[UIView alloc] initWithFrame:cell.frame];
    bgView.backgroundColor = [UIColor clearColor];
    cell.backgroundView = bgView;
    

    试试上面的代码

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-30
      • 1970-01-01
      • 2011-04-22
      • 1970-01-01
      • 2012-06-18
      • 2014-08-10
      • 2012-05-18
      相关资源
      最近更新 更多