在iPhone4上加载@ 2x图像失败?

时间:2010-08-27 11:28:32

标签: iphone ios

我的代码如下所示。我该怎么办?

UIImage *image = [UIImage imageWithContentsOfFile: 
                  [[NSBundle mainBundle] pathForResource:@"back" 
                                                  ofType:@"png"
                                             inDirectory:@"data/ui/button"]];

包含以下代码的精彩文章:http://atastypixel.com/blog/uiimage-resolution-independence-and-the-iphone-4s-retina-display/

2 个答案:

答案 0 :(得分:0)

如上所述链接的文章,请使用[UIImage imageNamed:@"image.png"]并确保您的图片位于捆绑包的根目录中。我建议不要使用文章中的类别,因为Apple将确保imageNamed将加载正确的图像,即使它们在将来的某个时间点转到4x图像;该类别对设备硬件进行了假设。

答案 1 :(得分:0)

为什么不使用imageWithContentsOfFile:方法代替imageNamed:方法? 我只将它用于我的图像并正确加载到iPhone 4 ...

相关问题