嘿大家,这似乎应该是一个简单的;我真的很希望它是。一如既往,先谢谢!iPhone:分组TableView背景图像问题
我想要做的是将一个背景图像添加到分组样式tableview。我使用在viewDidLoad中下面的方法:
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
不幸的是,background.png似乎如下要绘制不仅是细胞的背后,却也对细胞的背景和标题:
alt text http://www.freeimagehosting.net/uploads/194449ffc1.png
我知道在这个网站上有几个问题可以解决类似的问题,但是我担心我什么都得不到。 How can I set the background of UITableView (the tableview style is "Grouped") to use an image?导致我
self.tableView.opaque = NO;
self.tableView.backgroundView = nil;
增加viewDidLoad中,并在配置我的单元格添加
cell.backgroundView = nil;
cell.opaque = NO;
。不用说,它不起作用。添加
cell.backgroundColor = [UIColor clearColor];
也没有工作。可悲的是,那是我最后的想法。如果可能的话,我真的很希望能够在不添加界面构建器中的背景的情况下做到这一点。我宁愿尽可能多地编程。我希望问这不是太贪心。再次感谢!
* * * 编辑: * * *
我碰到另一种方法来实现这一点,但遇到了另一个问题。我下面的代码添加到viewDidLoad中:
UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
bgView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
[self.tableView.window addSubview:bgView];
[self.tableView addSubview:bgView];
[self.tableView sendSubviewToBack:bgView];
它看起来有前途的,它可能是,但不幸的是在给我的以下内容: alt text http://www.freeimagehosting.net/uploads/c02dd68e20.png
看起来好像它要么是没有被发送到后面和标题以某种方式显示出来,或者细胞跟着它回来。我一点也不确定。任何建议在这里也将不胜感激。
这里就是我发现的编辑代码: Add UIView behind UITableView in UITableViewController code