Is [Uiscreen Mainscreen].Bounds.Size Becoming Orientation-Dependent in Ios8

Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8?

Yes, it's orientation-dependent in iOS8, 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

[UIScreen mainScreen].bounds.size differences between iOS 7 and iOS 8

Yes, you would need to programmatically check the OS version and return the appropriate value. Here's one way to check: How can we programmatically detect which iOS version is device running on?.

iOS 8.x alternative to detect iPhone 5s, using [UIScreen mainScreen].bounds.size.height == 568.0

I was able to detect the devices using the following macros. This will be useful if you want identify the device, to perform some update on views(like updating frames on orientation changes). If you exactly want the device model/make, use this link (ios iphone get device model and make?) instead.

#define IS_IPHONE       ((int)(MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)) == 480)
#define IS_IPHONE5 ((int)(MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)) == 568)
#define IS_IPHONE6 ((int)(MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)) == 667)
#define IS_IPHONE6PLUS ((int)(MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)) == 736)

[UIScreen mainScreen].bounds Different iOS 8?

iOS8 bounds are relative to orientation thus a device in landscape will have different bounds from the same one on portrait , in iOS7 this does not happen, the bounds are the same no matter if you are in portrait or landscape

See this answer

UIScreen bounds smaller than expected on external screen

I figured this out. It was to do with [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8. I got the clue from this post:

Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8?

iPad wrong [[UIScreen mainScreen] bounds].size dimensions

The screen size will always be the same regardless of device orientation. The same with the key window size. The view controllers are the ones that rotate inside the window. So you either rotate your view if you're adding it to the window directly or simply add it to the root view controller, which will have a correct size.

For example:

UIWindow* keyWindow = [UIApplication sharedApplication].keyWindow;
UIViewController* rootController = keyWindow.rootViewController;

CGSize screenSize = [UIScreen mainScreen].bounds.size;
CGSize windowSize = keyWindow.bounds.size;
CGSize rootControllerSize = rootController.view.frame.size;
CGSize rootControllerBoundsSize = rootController.view.bounds.size;
CGAffineTransform rootTransform = rootController.view.transform;

NSLog(@"Screen size: %@", NSStringFromCGSize(screenSize));
NSLog(@"Window size: %@", NSStringFromCGSize(windowSize));
NSLog(@"RootController frame size: %@", NSStringFromCGSize(rootControllerSize));
NSLog(@"RootController bounds size: %@", NSStringFromCGSize(rootControllerBoundsSize));
NSLog(@"RootController transform: %@", NSStringFromCGAffineTransform(rootTransform));

if executed in landscape will print the following:

Screen size: {768, 1024}
Window size: {768, 1024}
RootController frame size: {768, 1024}
RootController bounds size: {1024, 768}
RootController transform: [0, 1, -1, 0, 0, 0]

The key here is the transform that it's applied to the root UIViewController when the device is rotated.

To obtain the screen size taking into account the device rotation you can use the root controller bounds size.

How to detect iPad orientation in iOS8 keyboard extension

You should use nativeBounds instead of bounds to make sure the result doesn't depends on the device orientation of the application while it is being launched.

extension UIDevice{
var detail:String {
if iPhone {
if UIScreen.mainScreen().nativeBounds.height == 480 {
return "iPhone Classic"
if UIScreen.mainScreen().nativeBounds.height == 960 {
return "iPhone 4 or 4S"
if UIScreen.mainScreen().nativeBounds.height == 1136 {
return "iPhone 5 or 5S or 5C"
if UIScreen.mainScreen().nativeBounds.height == 1334 {
return "iPhone 6"
if UIScreen.mainScreen().nativeBounds.height == 2208 {
return "iPhone 6+"
} else if iPad {
if UIScreen.mainScreen().nativeBounds.height == 1024 {
return "iPad Classic"
if UIScreen.mainScreen().nativeBounds.height == 2048 {
return "iPad Retina"
} else {
return "Undefined"

return "test"
var iPhone:Bool {
return UIDevice.currentDevice().userInterfaceIdiom == .Phone
var iPad:Bool {
return UIDevice.currentDevice().userInterfaceIdiom == .Pad
var width:CGFloat{
return UIScreen.mainScreen().bounds.width
var landscape:Bool {
if iPad && ( width == 1024.0 || width == 2048.0 ) {
return true
if iPhone && ( width == 480.0 || width == 960 || width == 1136.0 || width == 1334.0 || width == 2208.0 ) {
return true
return false
if UIDevice().iPhone {
println("This device is an iPhone")
if UIDevice().iPad {
println("This device is an iPad")
println("Device detail: " + UIDevice().detail )
println("Landscape: " + UIDevice().landscape.description )

Related Topics

Leave a reply