OGeek|极客世界-中国程序员成长平台

标题: ios - ipad mini 的图像命名约定 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 10:55
标题: ios - ipad mini 的图像命名约定

我对通用应用程序中的图像命名约定有疑问,尤其是对于 ipad mini。

我正在开发一个跨 iphone 4s、ipad 3(即带有视网膜的 ipad)和 ipad mini 的通用应用程序。我有一张我想在应用程序中加载为背景的图像。我正在使用

[UIImage imageNamed"background"] 

获取图像。这适用于 iphone 和 ipad,但不适用于 ipad mini。

为了调试,我使用了

NSString *filePath = [[NSBundle mainBundle] pathForResource"background" ofType"png"];
NSLog(@"background image: %@",filePath);

以确保选择了正确的图像。在 ipad 上我得到了

background image: /var/mobile/Applications/[...RESOURCEPATH...]/background.png

在 iPhone 上我得到了

background image: /var/mobile/Applications/[...RESOURCEPATH...]/background~iphone.png

但在 ipad mini 上我得到了

background image: (null)

真正奇怪的是,我已经包含了图像的命名版本:

background~iphone.png
background@2x~iphone
background-Portrait~ipad
background-Portrait@2x~ipad

但不是 background.png 本身。

当我意识到这个错误时,我添加了 background.png 图像,现在我的背景也出现在了 mini 上。

这里发生了什么,正确的方法是什么?



Best Answer-推荐答案


您会在图像名称中看到“修饰符”(如“-PortraitUpsideDown”)的唯一位置是启动图像,如 this Apple documentation (look in the "roviding Launch Images for Different Orientations" section) 中所述.

你真的应该只有两张背景图片。一种用于常规分辨率,一种用于 Retina 分辨率(即“@2x”后缀)。这两个图像应该能够很好地处理旋转。

关于ios - ipad mini 的图像命名约定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16492008/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4