Orientation Method not working for iPhone plus devices

Viewed 109

Below mentioned orientation delegate method not calling in case of iOS plus devices(iPhone 8plus/7plus/6plus...)

My code for orientation methods is:

Note: Landscape right checkbox is unselected by default.

- (BOOL)shouldAutorotate {
    return NO;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscapeRight;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
     return UIInterfaceOrientationLandscapeRight;
}

My info.plist file is:

<key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>

Please guide me on this issue.

1 Answers

Try adding a notification on view

UIDeviceOrientationDidChangeNotification

and check if it comes in the method.

Also you are returning No in your UIDeviceOrientationDidChangeNotification method try returning YES.

Hope this helps. Do let me know if you need any more explanation. This approach has been worked for me.

Related