objective-c - 在 Xcode 中为 iPad 指定图像,例如为 iPhone 4 指定 @2x

标签 objective-c xcode ios ipad

我已经将我当前的目标升级到 iPad 并制作了一个通用应用程序,如果这个问题有答案,将我的 iphone 应用程序调整到 ipad 的时间将大大减少。

此时每个人都知道如果您有一张名为“football.png”的图片并希望支持 Retina Display,您应该将图片的大小加倍并将其命名为“football@” 2x.png".

我的问题是是否有类似 *football@iPad_which_is_another_size.png* 的适用于 iPad 的东西?

如果没有办法做到这一点,我是否必须将每个图像连接到 IBOutlet 并以编程方式设置框架?

最佳答案

In iOS 4.0 and later, it is possible to mark individual resource files as usable only on a specific type of device To associate a resource file with a particular device, you add a custom modifier string to its filename. The inclusion of this modifier string yields filenames with the following format:

 <basename><device>.<filename_extension>

要加载特定于 iPad 的资源,您应该使用 ~ipad。示例:创建名为 AwesomeImage~ipad.png 的图像并使用 [UIImage imageNamed:@"AwesomeImage.png"] 加载,就像您对视网膜显示图像所做的那样。

更多信息:http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/LoadingResources/Introduction/Introduction.html 在“iOS 支持特定于设备的资源”部分。

关于objective-c - 在 Xcode 中为 iPad 指定图像,例如为 iPhone 4 指定 @2x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5535630/

相关文章:

iPhone XCode 创建与日期相关的 if 语句

ios - XCode 9 - 导入#import <objc/runtime.h> 时出错 - 仅适用于模拟器

objective-c - Nil 合并运算符 Swift

objective-c - 比较 Objective-C 中的时间和日期

ios - XCode:组织者不再显示崩溃报告

iOS 将 View 底部的约束添加到容器中心

ios - 使用 XCTest 添加图像到 ALAssetsLibrary

iphone - NSDateComponents 给出奇怪的结果

iphone - 在 4.3.3 设备上从 xcode 构建/运行 IOS 5.0

ios - 通过标签将照片从 Instagram 返回到我的 ios 应用程序