2012-08-11 163 views
0

我在我的iOS应用程序中看到了设置视图,由UITableView提供。这个应用程序是通用的,所以你可以在iPhone和iPad上运行它。该表应该具有自定义背景。并使用此代码设置图像的背景:iPad上UITableView的背景图像

table.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"settings_bg"]]; 

这是iPhone OK:

enter image description here

但在iPad这样的背景是灰色的!

enter image description here

为什么?我应该如何为iPad设置自定义背景?日Thnx。

回答

1

这在某种程度上是分组模式下iPhone和iPad UITableView行为的已知区别。使用此代码,而不是(或类似):

if ([self.tableView respondsToSelector:@selector(backgroundView)]) { 
    [self.tableView setBackgroundView:nil]; 
    UIView* bkgView = [[[UIView alloc] initWithFrame:self.tableView.bounds] autorelease]; 
    bkgView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:...]]; 
    [self.tableView setBackgroundView:bkgView]; 

} 
+0

仍然没有工作的iPad ..但确定为iPhone – 2012-08-11 08:42:34

+0

对不起,这是为我工作... – sergio 2012-08-11 10:16:17

+0

什么或者是像你引用?或者你的意思是说,作为占位符? – 2012-08-11 12:34:41