I'm building a landscape app in Xcode 6. When I run it on the iOS 8.3 simulator, [UIScreen mainScreen].bounds
is 667x375
, but when I run it on an iPhone 6 iOS 8, [UIScreen mainScreen].bounds
is 375x667
. This is causing problems for my app as many elements are sized with the screen bounds. I know [UIScreen mainScreen].bounds
changed in iOS 8, but that's not the issue. It should be 667x375
on both the device and simulator.
I'd provide code, but I have no idea where the issue is.
Asked
Active
Viewed 1,544 times
0

TheCodeMan54
- 143
- 2
- 5
3 Answers
1
iOS 8.3 iPhone6 Simulator
Portlait
bounds:{{0, 0}, {375, 667}}
applicationFrame:{{0, 20}, {375, 647}}
nativeBounds:{{0, 0}, {750, 1334}}
Landscape
bounds:{{0, 0}, {667, 375}}
applicationFrame:{{0, 0}, {667, 375}}
nativeBounds:{{0, 0}, {750, 1334}}
iOS 8.3 iPhone6 Device
Portlait
bounds:{{0, 0}, {375, 667}}
applicationFrame:{{0, 20}, {375, 647}}
nativeBounds:{{0, 0}, {750, 1334}}
Landscape
bounds:{{0, 0}, {667, 375}}
applicationFrame:{{0, 0}, {667, 375}}
nativeBounds:{{0, 0}, {750, 1334}}
On iOS 8.3, the simulator and device's results are exactly same. If reported situation only occurs on the iOS 8 device, how about targeting your application to iOS 8.3 ?

Satachito
- 5,838
- 36
- 43
-
This was my experience also (on iOS 8.1.3, 8.2, and 8.3). – zpasternack Apr 22 '15 at 02:53
0
On iOS8, the window's frame will change as the device orientation. I think 667x375 is the size when your device is landscape.

user3349433
- 480
- 2
- 11
-
Then why does my iPhone 6 NSLog that the orientation is `375x667` while running the app with no changes on the iPhone 6 simulator NSLogs `667x375`? – TheCodeMan54 Apr 22 '15 at 02:35
-
1May be your simulator is landscape on one 6+ and portrait on 6. Please try to adjust your simulator's orientation by cmd+left/right. – user3349433 Apr 22 '15 at 02:39
-
Thanks for the suggestion, but my simulator is in landscape. The app actually works fine in the simulator, but not the device. The physical device is what seems to be giving incorrect bounds. – TheCodeMan54 Apr 22 '15 at 02:41
-
Are your trying to get the value in viewDidLoad or something similar? The value is invalid at that time. If so, you should get the correct bounds in viewDidLayoutSubviews or viewDidAppear. – user3349433 Apr 22 '15 at 02:45
-
Im trying to use the screen bounds to set my view size. The view ends up "portrait" even though the device is landscape (due to the weird bounds). – TheCodeMan54 Apr 22 '15 at 02:54
0
Here's a quick class method I use to change the screen size back to what it was before iOS 8 (switch height and width)
+ (CGSize)getScreenSize {
CGSize screenSizeRef = [[UIScreen mainScreen] bounds].size;
if (screenSizeRef.width > 450 && UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) {
// iPhone 6+ width on portrait is 414
return CGSizeMake(screenSizeRef.height, screenSizeRef.width);
}
if (screenSizeRef.width > 900 && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return CGSizeMake(screenSizeRef.height, screenSizeRef.width);
}
return screenSizeRef;
}
So instead of calling [[UIScreen mainScreen] bounds]
, put this method in a new class (so you can access it from anywhere in the program) and set your screen size reference to the return value of getScreenSize

tpatiern
- 415
- 4
- 13