有什么方法可以在 UITableViewController 上设置背景 View 吗?
我尝试使用在 UIViewController
上使用的代码,但 View 覆盖了 TableView 的所有内容。如果我在 cellForRowAtIndexPath-method 中添加背景 View ,它根本不会显示。有没有人以前做过这个或者知道如何做到这一点?
这是我正在使用的代码:
UIImage *image = [UIImage imageNamed: @"background.jpg"];
UIImageView *backImage = [[UIImageView alloc] initWithImage: image];
[self.view addSubview: backImage];
[self.view sendSubviewToBack: backImage];
最佳答案
我知道已经过去很长时间了,但只是为了记录一下。
我想我使用 UITableView.backgroundView
找到了更好的解决方案:
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"lisbon.png"]];
self.tableView.backgroundView = imageView;
[imageView release];
我在 iPhone 上尝试过使用 320x480 的图像尺寸,效果非常好(我也尝试过使用 .jpg)。
关于iPhone - 在 UITableViewController 上设置背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/898351/