Ask the orientation of the iphone device to update

I am creating a puzzle game for iphone. All my menus, etc. They are only in portrait orientation, but my gameplay can be both in portrait and in landscape.

So, when I’m on the menu and the device is held in the landscape, then when I go to the gameplay viewing controller, it makes a layout with landscape coordinates, but the screen is still actually portrait oriented:

enter image description here

I want to get the device to reorient the screen before I make the layout. How to do it?

right now I'm testing device orientation as follows:

- (void) viewDidLoad {
    .
    .
    .

   if (!UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation])) {
      // Run Portrait Layout
   }
   else {
      // Run Landscape Layout
   }
}

So, I know that the device returns the orientation of the landscape, but for some reason the screen is still portrait oriented.

+5
2

, ..

[UIViewController attemptRotationToDeviceOrientation];

viewDidLoad viewWillAppear,

+16

UIViewController , , :

willRotateToInterfaceOrientation:duration:willAnimateRotationToInterfaceOrientation:duration:didRotateFromInterfaceOrientation:

UIViewController

+1

All Articles