Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
228 views
in Technique[技术] by (71.8m points)

ios - iPhone 6 (Plus) screen size

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

However, I am confused when testing my app in the simulator. I have the following code in 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:

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 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 Plus: 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?

Thanks for explanation.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...