0

In iOS 8 bounds of ownership UIScreen class now reflects the orientation of the device. To fix this, I could use new nativeBounds of the property, instead of bounds. nativeBounds is measured in pixels. So what code what I put for pixels in ....... area? (this code is in my AppDelegate.m)

     [ [ UIScreen mainScreen ] respondsToSelector: @selector( nativeBounds ) ];

  if (................... == 1334) { 

        UIStoryboard *iPhone6 = [UIStoryboard storyboardWithName:@"iPhone6" bundle:nil];

        UIViewController *initialViewController =[iPhone6 instantiateInitialViewController];

        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]];

        self.window.rootViewController = initialViewController;

        [self.window makeKeyAndVisible];
   }

OR do I have the entire code implemented wrong for nativeBounds?

screenBounds doesn't work...

    CGRect screenBounds=[[UIScreen mainScreen] bounds];

    if (screenBounds.size.height == 667) {  //code }
Jet
  • 555
  • 1
  • 7
  • 19
  • Can you provide some more details – what's exactly your goal? You want to choose NIB filed based on current screen dimensions or something? Why are you comparing with static dimensions values like 667? – Denis Mysenko Mar 18 '15 at 05:46
  • My app uses Portrait and Upside Down orientation only. With the above code Upside Down orientation wouldn't work. In other words, when the simulator or device is upside down, it wouldn't turn portrait like it should. The above code is what stops the Upside Down orientation from working. That was my problem. – Jet Mar 18 '15 at 19:10

1 Answers1

0

You can use screenBounds:

let screenBounds: CGRect = UIScreen.mainScreen().bounds

//additionally you can use these two lines to make upcoming code shorter
let screenWidth = screenSize.width
let screenHeight = screenSize.height

if (screenHeight == 1334) {
    //code goes here
}
LinusGeffarth
  • 27,197
  • 29
  • 120
  • 174
  • screenBounds also doesn't work. The code for screenBounds I edited into above original code. Doesn't work. – Jet Mar 18 '15 at 00:33