3

I am making an app which supports only portrait orientation in some pages, while in others, it supports only landscape mode. The problem I am facing is when I'm in landscape mode in one of the pages (I don't allow orientation change on screen rotation), and I press the home button to take the app into background mode,then when I come back into the app, it opens in portrait mode. How can I check and change device orientation in appWillEnterForeground method/ when app returns to foreground?

Subho M
  • 31
  • 3

1 Answers1

2

(already answered here: How to check the orientation of device programmatically in iPhone? )

However, check out property orientation of UIDevice ( [UIDevice currentDevice].orientation ), for example:

Landscape:

if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
{
     // code for landscape orientation      
}

Portrait:

if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation))
{
     // code for Portrait orientation       
}
Community
  • 1
  • 1
Andre
  • 1,135
  • 9
  • 20
  • yes, but I have to forcefully change the device orientation to landscape mode when I return back to the app from background, as now if I press the home button while the app runs in landscape mode, then when I come back, it opens in portrait mode. – Subho M Oct 16 '14 at 05:34