Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 当viewcontroller处于纵向时,如何以横向方式制作uiwebview youtube视频_Objective C_Xcode_Uiwebview_Uiinterfaceorientation - Fatal编程技术网

Objective c 当viewcontroller处于纵向时,如何以横向方式制作uiwebview youtube视频

Objective c 当viewcontroller处于纵向时,如何以横向方式制作uiwebview youtube视频,objective-c,xcode,uiwebview,uiinterfaceorientation,Objective C,Xcode,Uiwebview,Uiinterfaceorientation,我在UIWebView中使用嵌入式youtube,我的viewcontroller处于纵向模式,但我无法在全屏环境中查看视频。我从Stackoverflow尝试了许多解决方案,但没有一个能在iOS 7上运行 当我遇到与你类似的问题时,我所做的是: 即使只是肖像,你也可以得到这个设备 方向 如果方向为横向,则可以通过旋转来变换状态栏,MPMoviePlayerController也是如此 这是我使用的代码(不过是针对iOS6的,所以可能会有所不同) -(void) receivedRotate:

我在UIWebView中使用嵌入式youtube,我的viewcontroller处于纵向模式,但我无法在全屏环境中查看视频。我从Stackoverflow尝试了许多解决方案,但没有一个能在iOS 7上运行

当我遇到与你类似的问题时,我所做的是:

  • 即使只是肖像,你也可以得到这个设备 方向
  • 如果方向为横向,则可以通过旋转来变换状态栏,MPMoviePlayerController也是如此
  • 这是我使用的代码(不过是针对iOS6的,所以可能会有所不同)

    -(void) receivedRotate: (NSNotification*) notification
    {
        UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
        //Using this part to find the view controller on top (the one that's showing the video in fullscreen).
    
        while (topController.presentedViewController) {
            topController = topController.presentedViewController;
        }
    
        //After a little testing, the class of that controller is MPInlineVideoFullscreenViewController
        if ([topController isKindOfClass:NSClassFromString(@"MPInlineVideoFullscreenViewController")]) {
            topController.view.transform = CGAffineTransformMakeRotation(M_PI_2);
    
            //The 20 and -20 are to prevent the movie from going over the status bar
            topController.view.frame = CGRectMake(0, 20, self.view.frame.size.width,self.tabBarController.view.frame.size.height - 20);
        }
    }
    

    当我遇到与你类似的问题时,我所做的是:

  • 即使只是肖像,你也可以得到这个设备 方向
  • 如果方向为横向,则可以通过旋转来变换状态栏,MPMoviePlayerController也是如此
  • 这是我使用的代码(不过是针对iOS6的,所以可能会有所不同)

    -(void) receivedRotate: (NSNotification*) notification
    {
        UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
        //Using this part to find the view controller on top (the one that's showing the video in fullscreen).
    
        while (topController.presentedViewController) {
            topController = topController.presentedViewController;
        }
    
        //After a little testing, the class of that controller is MPInlineVideoFullscreenViewController
        if ([topController isKindOfClass:NSClassFromString(@"MPInlineVideoFullscreenViewController")]) {
            topController.view.transform = CGAffineTransformMakeRotation(M_PI_2);
    
            //The 20 and -20 are to prevent the movie from going over the status bar
            topController.view.frame = CGRectMake(0, 20, self.view.frame.size.width,self.tabBarController.view.frame.size.height - 20);
        }
    }
    

    它不起作用,因为你没有努力理解你必须做什么。你应该学习如何调试项目(在这种情况下,我100%确定你甚至没有看这个函数是否正在执行)不。你应该添加旋转手势通知识别器。thanx@LordZsolt NSClassFromString(@“MPInlineVideoFullscreenViewController”)为我工作…它不起作用,因为你没有努力理解你必须做什么。你应该学习如何调试项目(在这种情况下,我100%确定你甚至没有看这个函数是否正在执行)不。你应该添加旋转手势通知识别器。thanx@LordZsolt NSClassFromString(@“MPInlineVideoFullscreenViewController”)为我工作。。。