下班了寫~
解決了之後找到了這個文章。他寫的差不多了。
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