我尝试了多种方法来设置未选定的表格单元格的背景图像,但没有成功:
1- In IB setting the image field
2- cell.contentView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"list.png"]];
3- cell.imageView.image = [UIImage imageNamed:@"list_selected.png"];
一切似乎都失败了。选定单元格的图像设置有效,但不适用于未选定的单元格。有人知道这里可能出了什么问题吗?
谢谢
最佳答案
尝试将backgroundView设置为图像的imageView。
Jason Moore 的代码示例(经过 TomH 的修正):
cell.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"foo.png"]] autorelease];
关于iphone - 设置自定义表格 View 单元格的背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2271274/