UItableView設定背景色ClearColor無效的問題

來源:互聯網
上載者:User

下班了寫~

解決了之後找到了這個文章。他寫的差不多了。

http://blog.csdn.net/xiaobo16/article/details/8102790

還原一下問題的情境!

本來是一個iphone的app。支援的好好的。

然後增加了ipad版本。

在login的頁面,有個username和password的tableview。

在iphone 4s iphone 5,ipad 3(都已經升到了6.0 及以上)等裝置上都是沒有問題的。

設定tableView背景色也沒通過代碼,只是 IB裡面設定一下background color 為 clear color:PS:很久以前的工程,當時還沒脫離IB。

然後突然來個一台ipad2 ,版本是5.0.1.然後就尷尬了。

login的頁面tableView的背景色說什麼都不能換。---前提:我的tableVIew是grouped,不是plain的。

然後我就先試了兩個color,發現不是這問題。然後我就試著設定一下backgroundView。----發現就好了。。

然後網上隨便搜搜原因,就找到上面哪個blog 也說遇到了類似的情況,好像和我情況是不太一樣。我在ios6以後的都是好的。莫名其妙在ipad的5.0.1版本上除了這個問題。解決嘛:就是這樣的了。tableView.backgroundView
= nil;tableView.backgroundColor = [UIColor clearColor];

The backgroundColor property is a property inherited from UIView, setting it to be clearColor allows the window/view
behind the table view to show through. This works fine on the iPhone but will no longer work on the iPad
because the backgroundView is in the way.

順著串連我又看到了入戲的評論,

That seemed to work.  I just did:

 

    UIView *theView = [[UIView alloc] initWithFrame:self.testTableView.frame];

    [theView setBackgroundColor:[UIColor clearColor]];

    [self.testTableView setBackgroundView:theView];

 

background is now clear.  Still seems like a bug though.  I feel like [tableView setBackgroundColor:[UIColor clearColor]]; should work.

It's not a bug, UITableView's grouped style has a view behind it to allow for more advanced things, like images. backgroundColor only works in plain-style table views.

 

Or at least that's how I understand it.

 

Erway Software

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.