视频关闭后方向问题:Cordova 2.1.0 + iOS 6

3
我正在开发一个需要播放全屏HTML5视频的Phonegap应用程序。
我的问题是,在使用Phonegap 2.1.0和iOS 6时,方向发生了变化。每次我退出全屏视频(按下完成按钮)时,即使应用程序被锁定在横向模式下,视频也会强制将我的应用程序切换到纵向模式。
我没有进行任何obj-c魔法操作,只是使用了标准的HTML5视频标签。
<video id="myvideo" src="goat.mp4" controls="" autobuffer=""></video>

我猜测是视频层覆盖在我的视图控制器上导致了方向的改变,但是怎样才能让它停止呢?

如果您有任何想法,将不胜感激!提前致谢...

1个回答

7

针对 PhoneGap 2.1 版本,请查看 错误修复

在 "MainViewController.m" 文件中将 viewWillAppear 更改为

- (void)viewWillAppear:(BOOL)animated
{
  // Set the main view to utilize the entire application frame space of the device.
  // Change this to suit your view's UI footprint needs in your application.

  UIView* rootView =[[[[UIApplication sharedApplication] keyWindow] rootViewController] view];
  CGRect webViewFrame = [[[rootView subviews] objectAtIndex:0] frame];  // first subview is the UIWebView
  if (CGRectEqualToRect(webViewFrame, CGRectZero)) { // UIWebView is sized according to its parent, here it hasn't been sized yet
      self.view.frame = [[UIScreen mainScreen] applicationFrame]; // size UIWebView's parent according to application frame, which will in turn resize the UIWebView
  }

  [super viewWillAppear:animated];
}

这真的拯救了我的一天。谢谢! - weisjohn
这个问题在2.2版本中修复了吗? - CWSpear
据我所知,该问题已在最新版本中修复。 - casper60
我在iOS 6.1和视频方面遇到了类似的方向问题:http://stackoverflow.com/questions/14687731/are-html5-video-tags-be-broken-in-ios-6-1-apps-using-uiwebview-phonegap - SomethingOn

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接