0

I have a weird issue which suddenly appeared. The problem is that my app seems to be scaling my views, when changing device from iPhone 6 to iPhone 6 Plus for instance. So if I have a title with a certain font size the same title with take up the same amount of space on the iPhone 6 Plus screen when all I want is for the size to be the same and just appear smaller on the larger device. Do anyone know how this happened and how to fix this?

I noticed by running:

NSLog(@"%f", [UIScreen mainScreen].bounds.size.width);
NSLog(@"%f", [UIScreen mainScreen].bounds.size.height);

That his generates the same output on all simulator devices:

320
568

I would expect it to be something different on the larger devices. Does this have anything to do with it?

Mattias Farnemyhr
  • 4,148
  • 3
  • 28
  • 49

4 Answers4

1

Did you add launch images for the iPhone 6 and 6 Plus devices? Otherwise it will run scaled in these resolutions (and the [[UIScreen mainScreen] bounds] call will return the bounds as if running in a 4-inch device).

gutenbergn
  • 494
  • 5
  • 14
0

Just add a new default png photo with 1136 height.

[[UIScreen mainScreen] bounds].size

will return new height of 4-inch screen.

casillas
  • 16,351
  • 19
  • 115
  • 215
0

It is not a bug. You could review session 214 from WWDC 2014 for more info: "View Controller Advancements in iOS 8"

Quote from the presentation:

  • UIScreen is now interface oriented:
  • [UIScreen bounds] now interface-oriented
  • [UIScreen applicationFrame] now interface-oriented
  • Status bar frame notifications are interface-oriented
  • Keyboard frame notifications are interface-oriented
casillas
  • 16,351
  • 19
  • 115
  • 215
0

You could still work around to get the different values. Here is the code:

  + (CGRect)screenBoundsFixedToPortraitOrientation {
        UIScreen *screen = [UIScreen mainScreen];

        if ([screen respondsToSelector:@selector(fixedCoordinateSpace)]) {
                        return [screen.coordinateSpace convertRect:screen.bounds toCoordinateSpace:screen.fixedCoordinateSpace];
        } 
        return screen.bounds;
    }
casillas
  • 16,351
  • 19
  • 115
  • 215