gpt4 book ai didi

ios - Youtube 视频无法在 iOS 8 中以横向模式播放

转载 作者:可可西里 更新时间:2023-11-01 04:05:41 25 4
gpt4 key购买 nike

我的应用程序包含以横向和纵向模式播放视频的功能。视频可以是 youtube,在 iOS 7 之前一切正常,但现在 youtube 视频在 iOS 8 上无法以横向模式工作。

我的代码:

- (NSUInteger)application:(UIApplication *)applicationsupportedInterfaceOrientationsForWindow:(UIWindow *)window {


if ([[window.rootViewController presentedViewController]
isKindOfClass:[MPMoviePlayerViewController class]] || [[window.rootViewController presentedViewController] isKindOfClass:NSClassFromString(@"MPInlineVideoFullscreenViewController")]) {

return UIInterfaceOrientationMaskAllButUpsideDown;
} else {

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

// look for it inside UINavigationController
UINavigationController *nc = (UINavigationController *)[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;
}

在 iOS 7 之前一切正常,但在 iOS 8 上停止工作。任何帮助表示赞赏

最佳答案

虽然回答自己的问题有时很愚蠢,但有助于帮助面临同样问题的其他人。

在 iOS 8 中,我们需要检查 AVFullScreenViewController 而不是检查 MPInlineVideoFullscreenViewController。下面是适用于所有 iOS 版本(即 iOS 8 及更低版本)的完整方法。

 - (NSUInteger)application:(UIApplication *)applicationsupportedInterfaceOrientationsForWindow:(UIWindow *)window {

if ([[window.rootViewController presentedViewController]
isKindOfClass:[MPMoviePlayerViewController class]] || [[window.rootViewController presentedViewController] isKindOfClass:NSClassFromString(@"MPInlineVideoFullscreenViewController")] || [[window.rootViewController presentedViewController] isKindOfClass:NSClassFromString(@"AVFullScreenViewController")]) {

return UIInterfaceOrientationMaskAllButUpsideDown;
}else {

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

// look for it inside UINavigationController
UINavigationController *nc = (UINavigationController *)[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;
}

更新:也适用于 iOS 9

关于ios - Youtube 视频无法在 iOS 8 中以横向模式播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25967615/

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