UITableViewCell backgroundView没有出现在设备上

时间:2012-02-13 13:10:17

标签: ios uitableview device cell

我有一个分组的表格视图,我添加了一个自定义的背景视图,我在代码中设置这些,并且所有在iOS模拟器上都适用于普通和视网膜iPhone,但在设备上它们根本没有显示,它只是一个没有背景的细胞。

我正在做以下事情:

UIImageView * imageview = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellbackground.png"]] autorelease];
UIImageView * imageviewSelected = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellbackgroundSelected.png"]] autorelease];
[cell setBackgroundView:imageview];
[cell setSelectedBackgroundView:imageviewSelected];

有没有人知道为什么这不会在设备上运行?我删除并重新安装它,我清理了构建文件夹和项目,但仍然没有背景。

2 个答案:

答案 0 :(得分:5)

检查图像文件名。信件案件有时很重要。在模拟器中“Apple.png”和“apple.png”将起作用。但在设备中它不会。

答案 1 :(得分:0)

尝试这个:

 tableView.backgroundColor = [UIColor clearColor];