【问题标题】:How to allow rotation of youtube fullscreen or AVFullscreenVideoController?如何允许 youtube 全屏或 AVFullscreenVideoController 旋转?
【发布时间】:2015-02-07 04:57:49
【问题描述】:

AVFullscreenVideoController 是在 ios8 中全屏播放 youtube 时的视图控制器。我可以通过操纵应用程序委托方法让它旋转

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
     /*
     if view controller is AVFullscreenVideoController or MPInlineVideoFullscreenViewController or MPMoviePlayerViewController"
     return UIInterfaceOrientationMaskAllButUpsideDown;
     */
}

我的目标是保留我的视图控制器的当前 UIInterfaceOrientationMask 并允许在播放时旋转到全屏视频。

如何在 appdelegate.m 中不添加代码也能达到同样的效果?谢谢!

【问题讨论】:

    标签: ios objective-c youtube-api autorotate


    【解决方案1】:

    我发现 fullscreenvideocontroller 取决于您允许设备执行的操作。在目标 > 常规 > 设备方向或应用委托中

    -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window;
    

    我只是确保如果我的 rootviewcontroller 是作为 rootviewcontroller 的导航控制器,我必须实现这些方法来将控制权交还给我的其他视图控制器

    -(BOOL)shouldAutorotate
    {
        return [[self.viewControllers lastObject] shouldAutorotate];
    }
    
    -(NSUInteger)supportedInterfaceOrientations
    {
        return [[self.viewControllers lastObject] supportedInterfaceOrientations];
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
    }
    

    如果呈现全屏视频控制器的视图控制器是严格纵向的,请参考这篇文章

    Allow video on landscape with only-portrait app

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-29
      • 2011-06-28
      • 2019-08-17
      • 2019-08-17
      • 2012-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多