3

我正在构建一个需要播放全屏 html5 视频的 Phonegap 应用程序。

我的问题是,在 Phonegap 2.1.0 和 iOS 6 中,方向发生了一些变化,每次我关闭全屏视频(按完成按钮)时,即使应用程序被锁定为横向模式,视频也会强制我的应用程序处于纵向模式。

我在这里没有做任何 obj-c 魔术,它是一个标准的 html5 视频标签。

<video id="myvideo" src="goat.mp4" controls="" autobuffer=""></video>

我认为是我的 viewController 顶部的视频层强制改变方向,但我该如何让它停止呢?

任何想法将不胜感激!提前致谢...

4

1 回答 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];
}
于 2012-10-15T16:34:41.223 回答