gpt4 book ai didi

ios - 在 iOS 10 中,如何允许视频在仅纵向 iOS 应用程序中显示时横向旋转

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:55:32 25 4
gpt4 key购买 nike

在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;
}

最佳答案

这是 Swift 中的一个有效解决方案。这个函数进入 AppDelegate

func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {

if let presentedViewController = window?.rootViewController?.presentedViewController {
let className = String(describing: type(of: presentedViewController))
if ["MPInlineVideoFullscreenViewController", "MPMoviePlayerViewController", "AVFullScreenViewController"].contains(className)
{
return UIInterfaceOrientationMask.allButUpsideDown
}
}

return UIInterfaceOrientationMask.portrait
}

关于ios - 在 iOS 10 中,如何允许视频在仅纵向 iOS 应用程序中显示时横向旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39952002/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com