在 UITabBarController 中的 UIWebView 中支持 HTML5 视频的横向模式
我在 UITabBarController 的 UINavigationController 中有一个 UIWebView。有时,UIWebView 显示的页面包含 HTML5 视频对象。
视频按预期开始播放,但不支持横向模式。
我认为这可能是因为并非 UITabBarcontroller 内的所有视图控制器都会自动旋转到横向模式(我听说过“UITabBarController 内的所有视图控制器都应该支持自动旋转到横向模式以使 UITabBarController 自动旋转)。
任何知道的人有什么解决方法可以在应用程序之外打开视频本身吗?
谢谢!
我会稍微改一下
措辞,但我觉得这不足以创建一个新问题。 我有以下层次结构:
UITabBarController
UINavigationController (NC-A)
UITableView
UIWebView (pushed from UITableView)
UINavigationController (NC-B)
A number of UITableViews
UINavigationController (NC-C)
A number of UITableViews
我想要 UIWebView(在 NC-A 中),有时包含 HTML5 视频对象(如上所述),支持横向模式(并在用户翻转手机本身时自动旋转/调整大小)
< em>但是我不想在 NC-B 和 NC-A 控制的视图中实现自动旋转
为了支持 UITabBarController 中的自动旋转,我读到“当前所有视图都位于顶部”每个选项卡都必须实现 shudAutorotateToInterfaceOrientation (并针对相关方向返回 YES)”。
有什么办法可以解决这个问题吗?
I've got a UIWebView inside a UINavigationController in a UITabBarController. Sometimes the pages displayed by the UIWebView contains HTML5 video objects.
The video starts playing as expected, but doesn't support landscape mode.
I think that this might be since not all of my view controllers inside the UITabBarcontroller autorotates to landscape mode (I've heard about the "all view controllers inside a UITabBarController should support autorotation to landscape mode to make the UITabBarController autorotate).
Anyone that knows any workaround? Possibly some solution to open the video itself outside of the app?
Thanks!
UPDATE 2011-03-15
I'll rephrase myself a bit, but I didn't feel it was enough to create a new question.
I've got the follow hierarchy:
UITabBarController
UINavigationController (NC-A)
UITableView
UIWebView (pushed from UITableView)
UINavigationController (NC-B)
A number of UITableViews
UINavigationController (NC-C)
A number of UITableViews
I want the UIWebView (in NC-A), which sometimes contains HTML5 video objects (like mentioned above), to support landscape mode (and autorotate/-resize when the user flips the phone itself)
But I don't want to implement the autorotation in the views controlled by NC-B and NC-A
To support the autorotation in a UITabBarController, I've read that "all views currently 'on top' in each of the tabs have to implement the shoudAutorotateToInterfaceOrientation (and return YES for the orientation in question)".
Is there any way to solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将是相当hacky的,但您可以在javascript中捕获html5视频的“播放”事件,然后触发您的webView委托将拦截的假URL。
从那里,构建一个 MPMoviePlayerController,将其附加到根视图控制器(或将其模态地放在其他所有东西之上),并按照您想要的方式设置自动旋转。
好处是保证用户使用本机电影播放器。缺点是它非常hacky。
It'd be fairly hacky, but you could capture the "play" event of the html5 video in javascript, then fire a fake URL which your webView delegate would intercept.
From there, build an MPMoviePlayerController, attach it to your root view controller (or put it up modally on top of everything else) and set your autorotation the way you want it.
Benefit is that the user is guaranteed the native movie player. Drawback is it's pretty hacky.
我采用的解决方案是以模态方式呈现 UIWebView。然后整个视图支持横向,因此 UIWebView 也支持横向。
The solution I went with was to present the UIWebView modally. Then the whole view supported landscape orientation and therefore also the UIWebView.