iPhone 6/iOS 8.3 上的屏幕尺寸错误? [英] Screen size is wrong on iPhone 6/iOS 8.3?

查看:162
本文介绍了iPhone 6/iOS 8.3 上的屏幕尺寸错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是偶然发现了一些非常奇怪和莫名其妙的东西.

I just stumbled on something very strange and baffling.

我在客户端应用程序中有代码,可根据屏幕大小加载不同的图像.

I have code in a client app that loads different images based on screen size.

我有使用当前屏幕来确定屏幕大小的代码.

I have code that uses the current screen to determine the screen size.

在我的 iPhone 6(实际设备,而非模拟器)上,它显示的屏幕尺寸为 320x568,这是 iPhone 5 屏幕的尺寸.

On my iPhone 6 (actual device, not simulator) it shows a screen size of 320x568, which is the size of the iPhone 5 screen.

如果我在 iPhone 6 sim 上运行完全相同的代码,屏幕尺寸会正确报告为 375x667.

If I run exactly the same code on the iPhone 6 sim, the screen size is reported correctly at 375x667.

为了去除所有无关的细节,我刚刚使用 Xcode 单视图项目模板创建了一个新项目.我使用了 Objective-C 以防它是一个 Swift 问题.我向 Xcode 创建的视图控制器添加了一个 viewWillAppear: 方法,如下所示:

To strip away all extraneous details, I just created a new project with the Xcode single view project template. I used Objective-C in case it was a Swift problem. I added a viewWillAppear: method to the view controller that Xcode creates that looks like this:

- (void) viewWillAppear:(BOOL)animated
{
  [super viewWillAppear:animated];
  UIScreen *screen = [UIScreen mainScreen];
  CGSize screenSize = screen.bounds.size;
  _label.text =[NSString stringWithFormat:
                @"Screen size = %@",
                NSStringFromCGSize(screenSize)];
}

Xcode 模板应用程序设置了 info.plist 的UILaunchStoryboardName"值为LaunchScreen",它实际上指的是一个名为LaunchScreen.xib"的 XIB 文件,该文件在所有设备上启动时显示.但是,iPhone 6 上报告的屏幕尺寸是错误的.

The Xcode template app is set up with an info.plist "UILaunchStoryboardName" value of "LaunchScreen", which actually refers to an XIB file called "LaunchScreen.xib" That XIB displays at launch time on all devices. However, the screen size reported on iPhone 6 is wrong.

我错过了什么?!?

推荐答案

我猜你的 iPhone 6 处于缩放模式,如下所述:

I'm guessing that your iPhone 6 is in zoomed mode, as described here:

https://support.apple.com/en-us/HT203073

在这种模式下,iPhone 6 实际上认为它是用于显示目的的 iPhone 5(并将 iPhone 5 大小的屏幕环境传达给所有应用).

In that mode, the iPhone 6 effectively thinks it is an iPhone 5 for display purposes (and communicates an iPhone 5-sized screen environment to all apps).

这篇关于iPhone 6/iOS 8.3 上的屏幕尺寸错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆