iPhone 6/iOS 8.3 上的屏幕尺寸错误?

编程入门 行业动态 更新时间:2024-10-28 04:21:15
本文介绍了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:

support.apple/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 上的屏幕尺寸错误?

本文发布于:2023-11-26 22:40:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635494.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   屏幕尺寸   iPhone   iOS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!