Using UIInterfaceOrientation to change screen

0

I need to know how to change the iPhone screen when it is rotated (From Portrait to Landscape).

For example, when you are in Portrait mode, you will see Screen A, when you are in Left Landscape it will display Screen B and when you turn to Right Landscape, the C screen will be displayed.

That is, it triggers the presentViewController:animated:completion: method when the screen orientation change occurs, or some other method that is specific to this behavior.

Thank you.

    
asked by anonymous 08.09.2014 / 21:12

1 answer

1

You can do this through the method:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

Before the orientation of the interface is changed, you check which orientation the application will go to and make the corresponding ViewController present.

It will be something like this:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {

        // Do Something

    } else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {

        // Do Something    

    } else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {

        // Do Something
    }
}
    
09.09.2014 / 15:56