ios iPhone 6 (Plus) 屏幕尺寸

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27268470/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 03:52:58  来源:igfitidea点击:

iPhone 6 (Plus) screen size

iosobjective-cios-simulatoriphone-6iphone-6-plus

提问by Cimlman

There were many articles written and questions asked about iPhone 6 and iPhone 6 Plus screen sizes. This articleprovides a great explanation.

有很多关于 iPhone 6 和 iPhone 6 Plus 屏幕尺寸的文章和问题。这篇文章提供了很好的解释。

However, I am confused when testing my app in the simulator. I have the following code in AppDelegate.

但是,在模拟器中测试我的应用程序时我很困惑。我在AppDelegate.

- (BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions
{
    UIScreen *screen = [UIScreen mainScreen];
    NSLog(@"Screen width %.0f px, height %.0f px, scale %.1fx",
          (double) screen.bounds.size.width,
          (double) screen.bounds.size.height,
          (double) screen.scale);

    return YES;
}

I get the following results from iOS simulator for various devices:

我从各种设备的 iOS 模拟器得到以下结果:

iPhone 4S: Screen width 320 px, height 480 px, scale 2.0x

iPhone 4S: Screen width 320 px, height 480 px, scale 2.0x

iPhone 5: Screen width 320 px, height 568 px, scale 2.0x

iphone 5: Screen width 320 px, height 568 px, scale 2.0x

iPhone 5S: Screen width 320 px, height 568 px, scale 2.0x

iPhone 5S: Screen width 320 px, height 568 px, scale 2.0x

iPhone 6: Screen width 320 px, height 568 px, scale 2.0x

iPhone 6: Screen width 320 px, height 568 px, scale 2.0x

iPhone 6 Plus: Screen width 320 px, height 568 px, scale 2.0x

iPhone 6 加: Screen width 320 px, height 568 px, scale 2.0x

The results are fine for iPhone 4S, iPhone 5 and iPhone 5S. However, I expect larger screen size for iPhone 6 and iPhone 6 Plus and I also expect scale 3.0 for iPhone 6 Plus. What is wrong?

结果适用于 iPhone 4S、iPhone 5 和 iPhone 5S。但是,我预计 iPhone 6 和 iPhone 6 Plus 的屏幕尺寸更大,我也预计 iPhone 6 Plus 的屏幕尺寸为 3.0。怎么了?

Thanks for explanation.

谢谢解释。

回答by Fahri Azimov

It seems like you didn't provide correct launch images to your app. When there is no correct launch images set, the app will run like on iPhone 5/5S, that's why you are having these confusing results while logging. iPhone 6 screen size is 375x667 px scale x2, iPhone 6+ 414x736 px scale x3. So, if you want to set launch image for iPhone 6 it should have 750x1334 px size, and 1242x2208 for iPhone 6+ respectively. Good Luck!

您似乎没有为您的应用提供正确的启动图像。当没有设置正确的启动图像时,该应用程序将像在 iPhone 5/5S 上一样运行,这就是为什么您在记录时会出现这些令人困惑的结果。iPhone 6 屏幕尺寸为 375x667 像素缩放 x2,iPhone 6+ 414x736 像素缩放 x3。所以,如果你想为 iPhone 6 设置启动图像,它的大小应该分别为 750x1334 像素和 1242x2208 的 iPhone 6+。祝你好运!

EDIT:

编辑:

As rmaddy mentioned in the comments, it's better to use launch screen storyboard with proper layout constraints to fit all screens, than having bunch of images for all screens(which also increases the app size).

正如 rmaddy 在评论中提到的,最好使用具有适当布局约束的启动屏幕故事板来适应所有屏幕,而不是为所有屏幕使用一堆图像(这也会增加应用程序的大小)。

回答by ChintaN -Maddy- Ramani

You have to add Launch Image in Imageasset for iPhone 6 and 6+ with proper resolution.

您必须在 iPhone 6 和 6+ 的 Imageasset 中添加具有适当分辨率的 Launch Image。

if you dont know resolution please check right side navigator > choose 3rd option. right now in screenshot you can see Expected size 1242x2208 pixel

如果您不知道分辨率,请检查右侧导航器 > 选择第三个选项。现在在截图中你可以看到Expected size 1242x2208 pixel

please check attached screenshot. once you add this all images then only you will get proper.

请检查附件截图。一旦你添加了所有图像,那么只有你会得到正确的。

for iPhone 6 it will log

对于 iPhone 6,它会记录

Screen width 375 px, height 667 px, scale 2.0x

屏幕宽度 375 px,高度 667 px,比例 2.0x

for 6+

6+

Screen width 414 px, height 736 px, scale 3.0x

屏幕宽度 414 px,高度 736 px,比例 3.0x

enter image description here

在此处输入图片说明

回答by Onik IV

Add a Launch Screen to your project, ->File -> New File -> in iOS User Interface -> Launch screen. Then in the General View of your App, select the LaunchScreen.xib in the Launch Screen File field. Try again your code, and you could see the real sizes.

将启动屏幕添加到您的项目中,-> 文件 -> 新建文件 -> 在 iOS 用户界面中 -> 启动屏幕。然后在应用程序的 General View 中,在 Launch Screen File 字段中选择 LaunchScreen.xib。再试一次你的代码,你可以看到真实的大小。

回答by ???

In my case, I found the settings in iPhone about the display. (Settings - Display & Brightness - DISPLAY ZOOM).

就我而言,我在 iPhone 中找到了有关显示器的设置。(设置 - 显示和亮度 - 显示缩放)。

If your setting is "Zoomed", screen width will be 320px.

如果您的设置是“缩放”,则屏幕宽度将为 320 像素。

回答by Jenny Cheung

For others who may come into the question:

对于可能遇到问题的其他人:

Make sure your launch image names are not the same with any other pictures in your project, otherwise Xcode may be confused and also returns iPhone 5 width and height.

确保您的启动图像名称与项目中的任何其他图片不同,否则 Xcode 可能会混淆并返回 iPhone 5 的宽度和高度。