Best way to Supporting Multiple Interface Orientations - iOS8

147 views Asked by At

I have been trying to convert few old apps written in objC long ago in iOS4 which support multiple ViewController with different orientation.

  • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

Above Method is called in app delegate from ViewController and Desire Orientation was set but seems stopped working with iOS8.

I have tried number of solution like creating Category of UINavigation controller etc, but nothing seems working with iOS8.

What is best approach to handle Multiple Orientation for both iPhone and iPad.

Furthermore, I am not using Storyboard with size classes, in plist i am only supporting portrait orientation.

2

There are 2 answers

0
Ankit Sachan On

From iOS 6 onwards, you've to use.

- (BOOL)shouldAutorotate {

    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

    if (orientation == UIInterfaceOrientationPortrait) {
        // your code for portrait mode
    }

    return YES;
}

Refer to shouldAutorotateToInterfaceOrientation not being called in iOS 6

0
Rajesh Maurya On

Check all the orientation you want to support in device. For that go to Project target-> Deployment info -> Device orientation-> Tick mark the desired orientation.