小编map*_*ple的帖子

在iOS 10中,如何在仅限肖像的iOS应用程序中显示时允许视频以横向旋转

在iOS 10之前,有两个通知 MPMoviePlayerWillEnterFullscreenNotificationMPMoviePlayerWillExitFullscreenNotification 让观察者进入全屏模式,但是在iOS 10中不推荐通知,那么如何在设备旋转时更改 UIInterfaceOrientationMask

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    if ([[self.window.rootViewController presentedViewController]
         isKindOfClass:[MPMoviePlayerViewController class]]) {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    } else {

        if ([[self.window.rootViewController presentedViewController]
             isKindOfClass:[UINavigationController class]]) {

            // look for it inside UINavigationController
            UINavigationController *nc = (UINavigationController *)[self.window.rootViewController presentedViewController];

            // is at the top?
            if ([nc.topViewController isKindOfClass:[MPMoviePlayerViewController class]]) {
                return UIInterfaceOrientationMaskAllButUpsideDown;

                // or it's presented from the top?
            } else if ([[nc.topViewController presentedViewController]
                        isKindOfClass:[MPMoviePlayerViewController class]]) {
                return UIInterfaceOrientationMaskAllButUpsideDown;
            }
        }
    }

    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

ios ios10

2
推荐指数
1
解决办法
1925
查看次数

标签 统计

ios ×1

ios10 ×1