【问题标题】:Native Resolution Verification for iPhone 6 and iPhone 6+iPhone 6 和 iPhone 6+ 的本机分辨率验证
【发布时间】:2015-02-02 15:55:00
【问题描述】:

尝试在 iPhone 6 和 6+ 的模拟器中以原始分辨率运行。我正在使用 Xcode 6。

已在 XCode 中以适当的分辨率安装 Launch Image。

iPhone 6 (Retina HD 4.7) 需要 750 x 1334 的纵向启动图像。

iPhone 6 Plus (Retina HD 5.5) 要求纵向和横向图像的尺寸分别为 1242 x 2208 和 2208 x 1242。

但在代码中,

[[UIScreen mainScreen] bounds].size.width
[[UIScreen mainScreen] bounds].size.height

得到

375.000000, 667.000000 for iphone 6 simulator
414.000000, 736.000000 for iphone 6+ simulator

如果图像被删除,则得到

 320.000000, 568.000000 for iphone 6 simulator
 320.000000, 568.000000 for iphone 6+ simulator

所以我猜排名靠前的数字证明我们处于高分辨率模式,但为什么我们没有获得真正的屏幕分辨率? iphone 6 是 /2 和 iphone 6+ / 3。或者这只是设计使然。

[添加]

我想我会添加这个脚本作为一个关于如何生成所有 XCODE 6 启动屏幕的示例......

必须安装 ImageMagick,使用没有 alpha 层的源文件。

convert black.png -resize 1024x768!  Launch-iPad-1024x768-Landscape-ios-5-6-1x.png
convert black.png -resize 1024x768!  Launch-iPad-1024x768-Landscape-ios-7-8-1x.png
convert black.png -resize 1536x2048! Launch-iPad-1536x2048-Portrait-ios-5-6-2x.png
convert black.png -resize 1536x2048! Launch-iPad-1536x2048-Portrait-ios-7-8-2x.png
convert black.png -resize 2048x1536! Launch-iPad-2048x1536-Landscape-ios-5-6-2x.png
convert black.png -resize 2048x1536! Launch-iPad-2048x1536-Landscape-ios-7-8-2x.png
convert black.png -resize 768x1024!  Launch-iPad-768x1024-Portrait-ios-5-6-1x.png
convert black.png -resize 768x1024!  Launch-iPad-768x1024-Portrait-ios-7-8-1x.png
convert black.png -resize 1242x2208! Launch-iPhone-1242x2208-Portrait-ios-8-HD-5.5.png
convert black.png -resize 2208x1242! Launch-iPhone-2208x1242-Landscape-ios-8.png
convert black.png -resize 320x480!   Launch-iPhone-320x480-Portrait-ios-5-6-1x.png
convert black.png -resize 640x1136!  Launch-iPhone-640x1136-Portrait-ios-5-6-Retina-4.png
convert black.png -resize 640x1136!  Launch-iPhone-640x1136-Portrait-ios-7-8-Retina-4.png
convert black.png -resize 640x960!   Launch-iPhone-640x960-Portrait-ios-5-6-2x.png
convert black.png -resize 640x960!   Launch-iPhone-640x960-Portrait-ios-7-8-2x.png
convert black.png -resize 750x1334!  Launch-iPhone-750x1334-Portrait-ios-8-HD-4.7.png

【问题讨论】:

  • [[UIScreen mainScreen] scale]; 是您可能正在寻找的从bounds 获得真实分辨率的乘数。
  • 谢谢,是的,这一切看起来就是它应该如何工作的。这是我第一次看到有关分辨率的详细信息。

标签: ios objective-c screen-resolution iphone-6 iphone-6-plus


【解决方案1】:

你可以使用[UIScreen mainScreen].nativeScale,如果正常,你可以使用2.6f,如果在iPhone 6 plus上放大,你可以使用2.8f,或者定义的宏:

#define IS_OS_8_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_5 (IS_IPHONE && ([[UIScreen mainScreen] bounds].size.height == 568.0) && ((IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale) || !IS_OS_8_OR_LATER))
#define IS_STANDARD_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0  && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale)
#define IS_ZOOMED_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0 && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale > [UIScreen mainScreen].scale)
#define IS_STANDARD_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0)
#define IS_ZOOMED_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0 && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale < [UIScreen mainScreen].scale)

这是屏幕是否缩放的屏幕边界

<UIScreenMode: 0x17802f240; size = 1242.000000 x 2208.000000> // STANDARD
<UIScreenMode: 0x178226be0; size = 1125.000000 x 2001.000000> // ZOOMED

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-23
    • 1970-01-01
    相关资源
    最近更新 更多