我在当前项目中遇到了一个问题,因此我启动了一个简单的应用程序来查看是否可以隔离问题。在我的应用委托(delegate)中,我隐藏了状态栏。
[application setStatusBarHidden:YES animated:NO];
在我的单一 View Controller 中,我有这段代码:
- (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];
}
该应用还设置为自动旋转。
现在,问题来了:当我播放 youtube 视频,进入全屏模式,将设备旋转 90 度,然后点击“完成”退出全屏时,整个界面仍然向下移动 20 像素,就好像它在容纳状态栏一样.我注意到在全屏观看视频时,ios 添加了一个状态栏,所以我猜这是问题的一部分。我已经看到 native 视频播放器也出现了问题。
有什么想法吗?
最佳答案
我最近在我的应用游戏指南:黑色行动 2 中使用了这种 YouTube 嵌入方法,我遇到了这个问题,并且在点击电影播放器的“完成”按钮时显示了 rootViewController。检查 rootViewController 上的“想要全屏”修复了 20 像素的偏移,并修复了在按下“完成”按钮后显示的 rootViewController 我将其添加到 rootViewController 中,它添加了一个 UIViewController(带有 tableView)作为正在使用的 child [presentViewControllerAnimated:(BOOL) completion:nil] 以显示带有 YouTube 视频嵌入的 ViewController。
现在一切正常...如果您想查看它的行为方式,请查看我的应用程序中的“视频”选项卡。
-(void)viewDidAppear:(BOOL)animated {
NSLog(@"Main View viewDidAppear...");
[super viewDidAppear:animated];
[self dismissViewControllerAnimated:YES completion:nil];
ios youtube iphone rotation statusbar mpmovieplayerviewcontroller
关于iphone - 全屏 youtube 视频、旋转和状态栏 (iOS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9233568/