首页 > 解决方案 > 方向方法不适用于 iPhone plus 设备

问题描述

下面提到的方向委托方法在 iOS plus 设备(iPhone 8plus/7plus/6plus...)的情况下不调用

我的定位方法代码是:

注意:横向右复选框默认未选中。

- (BOOL)shouldAutorotate {
    return NO;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscapeRight;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
     return UIInterfaceOrientationLandscapeRight;
}

我的 info.plist 文件是:

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

请在这个问题上指导我。

标签: iosobjective-cscreen-orientation

解决方案


尝试在视图中添加通知

UIDeviceOrientationDidChangeNotification

并检查它是否出现在方法中。

此外,您在UIDeviceOrientationDidChangeNotification方法中返回 No 尝试返回 YES。

希望这可以帮助。如果您需要更多解释,请告诉我。这种方法对我有用。


推荐阅读