Search code examples
iosobjective-cios8screen-sizeiphone-6

Screen size is wrong on 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.

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

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

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)];
}

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.

What am I missing?!?


Solution

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

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

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