全屏YouTube视频,旋转和状态栏(iOS) [英] Fullscreen youtube video, rotation, and the status bar (iOS)

查看:2221
本文介绍了全屏YouTube视频,旋转和状态栏(iOS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在当前项目中遇到了一个问题,所以我创建了一个简单的应用程序,看看我是否可以隔离问题。在我的app委托中,我隐藏了状态栏。

I came across an issue in my current project, so I spun up a simple app to see if I could isolate the problem. In my app delegate I hide the status bar.

[application setStatusBarHidden:YES animated:NO];

在我的单视图控制器中,我有以下代码:

In my single view controller I have this code:

- (void)loadVideo
{
    // HTML to embed YouTube video
    NSString *youTubeVideoHTML = @"<html><head>\
    <body style=\"margin:0\">\
    <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
    width=\"%0.0f\" height=\"%0.0f\"></embed>\
    </body></html>";

    // Populate HTML with the URL and requested frame size
    NSString *html = [NSString stringWithFormat:youTubeVideoHTML, @"http://www.youtube.com/watch?v=VDRoBnL1gRg", 500, 500];

    // Load the html into the webview
    [self.webview loadHTMLString:html baseURL:nil];
}

该应用也设置为自动旋转。

The app is also set to autorotate.

现在,问题在于:当我播放YouTube视频时,进入全屏模式,将设备旋转90度,点击完成退出全屏,整个界面仍然向下移动20像素,就好像它是容纳状态栏。我注意到,当全屏观看视频时,ios会添加一个状态栏,所以我猜这是问题的一部分。我也看到了原生视频播放器出现的问题。

Now, here's the problem: When I play the youtube video, enter fullscreen mode, rotate the device 90 degrees, and hit "Done" to exit fullscreen, the entire interface remains shifted down 20px as if it were accommodating a status bar. I noticed that when viewing a video in full screen, ios adds a status bar, so I'm guessing that's part of the issue. I've seen the problem occur with the native video player as well.

有什么想法吗?

推荐答案

我最近使用这个YouTube嵌入方法为我的应用程序游戏指南:黑色行动2,我遇到这个问题,同时在点击电影播放器​​的完成按钮时显示rootViewController。检查rootViewController上的Wants Full Screen修复了20像素的移位,并修复了按下完成按钮后显示的rootViewController我将其添加到rootViewController,它正在添加一个UIViewController(带有tableView)作为正在使用的子节点[presentViewControllerAnimated:(BOOL)完成:nil]显示带有YouTube视频嵌入的ViewController。

I used this YouTube embed method recently for my app Game Guide: Black Ops 2, and I was having this problem along with being shown the rootViewController when hitting the movie player's "done" button. Checking "Wants Full Screen" on the rootViewController fixed the 20 pixel shift, and to fix the rootViewController being displayed after pushing the "done" button I added this to the rootViewController which was adding a UIViewController (with tableView) as a child which was using [presentViewControllerAnimated:(BOOL) completion:nil] to show the ViewController with the YouTube Video Embed.

现在一切正常...请查看我的视频选项卡应用程序,如果你想看看它的行为。

Now everything is working perfectly... check out the Videos tab in my app if you want to see how it behaves.

-(void)viewDidAppear:(BOOL)animated {
    NSLog(@"Main View viewDidAppear...");
    [super viewDidAppear:animated];
    [self dismissViewControllerAnimated:YES completion:nil];

}

ios youtube iphone 轮换 状态栏 mpmovieplayerviewcontroller

这篇关于全屏YouTube视频,旋转和状态栏(iOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆