iphone 4 - 加载图像x旧设备

Spa*_*Dog 0 iphone ipad

Apple说你必须有你的图像的@ 2x版本,并使用类似的东西

UIImage* anImage = [UIImage imageNamed:@"Button"]; // without the extension
Run Code Online (Sandbox Code Playgroud)

这将选择Button图像的低版本和雇用版本,具体取决于iPhone版本(3G/3GS或4).但是,如果该应用程序也适用于iPad呢?

即使我没有指定扩展名,iPad也会加载Button图像吗?

谢谢.

ken*_*ytm 6

即使我没有指定扩展名,iPad也会加载Button图像吗?

不,从文档:

  • 特别注意事项

    在iOS 4及更高版本中,不需要文件名来指定文件扩展名.在iOS 4之前,您必须指定文件扩展名.

由于iPad运行3.2,您需要包含该.png部分.但是,写作

UIImage* anImage = [UIImage imageNamed:@"Button.png"];
Run Code Online (Sandbox Code Playgroud)

不会阻止系统Button@2x.png在4.0上找到.