0

Things are easy to handle if the user rotates the device (I handle the call of viewWillTransitionToSize), but the app has to know its initial orientation.

Until now, I have been using the status bar orientation and device orientation

if (UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation))
{
//
}

if (INTERFACE_IS_PHONE && UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation) ) { 
 //
}


UIInterfaceOrientation orientation = [UIDevice currentDevice].orientation;

if (INTERFACE_IS_PHONE && UIDeviceOrientationIsPortrait(orientation) ) {
 //
 }

above methods showing wrong orientation ,any ?

Sanju
  • 1,148
  • 11
  • 26
  • Maybe this could help [link](http://stackoverflow.com/a/26132456/1492173). Put `UIInterfaceOrientation fromOrientation = [[UIApplication sharedApplication] statusBarOrientation];` as the first line in your `viewWillTransitionToSize:withTransitionCoordinator:` – Yevhen Dubinin Feb 12 '16 at 14:46
  • I'd argue you don't need orientation really. Since iOS 8, size classes + view size gives you the information you need to layout your view correctly. Orientation is getting to be more and more irrelevant with modern UIKit. – Léo Natan Feb 12 '16 at 15:01
  • Thanks @EugeneDubinin – Sanju Feb 18 '16 at 12:29
  • Thanks for commenting @LeoNatan – Sanju Feb 18 '16 at 12:30

0 Answers0