iPhone旋转和全屏视频 [英] iPhone rotation and full-screen video

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

问题描述

我遇到了一个奇怪的问题,需要我解决.我的应用始终以纵向模式运行-我明确希望这样做.在应用程序的一个地方,我有一个UIWebView,它可以按预期正常工作.该网络视图不会一直显示,而是会根据用户操作动态添加到主视图中并删除(即仅在需要时才可见).

I've encountered a strange issue, which I need help resolving. My app is always run in portrait mode - I explicitly want it to be that way. In one place in the app I have a UIWebView, which works just fine, as expected. This web view is not shown all the time but is dynamically added to the main view and removed based on user actions (i.e. it's only visible when I need it to).

现在,有时在此视图下,我可能会有youtube视频. WebView仅包含嵌入youtube的<iframe>.当用户单击Web视图中的视频预览框架时,将启动全屏视频查看器来播放视频-很好.

Now, sometimes in this view I may have a youtube video. The WebView simply contains the <iframe> for the youtube embed. When a user clicks on the video preview frame in the webview, a full-screen video viewer is launched to play the video - which is just fine.

但是,如果在播放过程中用户旋转手机,则全屏视频播放器将旋转并且视频以横向模式播放.现在,视频停止了,并且用户在不将手机旋转回纵向模式的情况下按下了完成"按钮,视频播放器关闭并且用户返回到我的应用程序-但是现在我的布局也旋转了!不仅是视频视图,还包括整个布局-带有工具栏,导航控制器等.

However if during the playback the user rotates the phone, the full-screen video player is rotated and the video is played in landscape mode. Now the video is stopped and the user presses "Done" button without rotating the phone back to portrait mode, the video player is closed and the user returns to my app - however now my layout is also rotated! Not just the video view, but the entire layout - with toolbar, navigation controller, etc.

我不希望任何轮换!我只希望我的应用程序中的所有内容都保持纵向模式!而且,现在即使将手机旋转回纵向,该应用程序仍将保持横向模式.

I don't want any rotation! I just want everything in my app to remain in portrait mode! Moreover, now even if the phone is rotated back to portrait, the app stays in landscape mode.

请注意,到目前为止,我目前仅在模拟器中进行了测试,因为我目前没有要测试的实体电话.我创建了一个简单的(质量很差!)视频(只是用一个旧的手机摄像头在屏幕上拍摄了模拟器)来演示该问题-视频在这里:

Note that I only tested this in a simulator so far, as I currently don't have a physical phone to test. I created a simple (bad quality!) video (just filmed the simulator on my screen with an old phone camera) to demonstrate the issue - the video is here: http://shchuka.com/hosting/rotation_problem.mp4

有什么主意我可以做什么?

Any ideas what I can do about it?

推荐答案

在其中添加或更改它:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    return (UIInterfaceOrientation == UIInterfaceOrientationPortrait);

}

这将阻止所有旋转,并且该应用程序将仅在纵向模式下运行.您可以将return语句放在IF语句中,以便在某些情况下可以轮换使用.

That will prevent all rotation and the app will only work in portrait mode. You can place the return statement within IF statements to allow rotation under certain circumstances.

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

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