防止UIWebView全屏旋转

发布于 2024-12-15 09:58:38 字数 159 浏览 5 评论 0原文

我有一个 UIWebView 可能会显示 YouTube 视频,因此当它发生时它会全屏显示。我的应用程序不旋转,但 UIWebView 旋转,所以如果我停止以横向模式观看它,当我返回屏幕时它会变得狂暴。

我如何监听用户点击完成或直接避免 UIWebView 旋转?

谢谢!

I have an UIWebView that might show a YouTube video, so when it happens it goes full screen. My app doesn't rotates, but the UIWebView rotates, so if i stop watching it in landscape mode, when i return to my screen it goes berserk.

How can i listen for when the user taps done or to directly avoid the UIWebView to rotate?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

忘东忘西忘不掉你 2024-12-22 09:58:38

我们经常有仅纵向应用程序,通过网络视图显示横向视频。

您确定从顶部视图控制器的 shouldAutorotateToOrientation: 方法返回横向方向为“否”吗?当你说“发狂”时,你是什么意思?我发现的一件事是,设置主窗口的 rootViewController 属性(而不是仅仅将根视图控制器的视图添加为窗口视图的子视图)在从此类视频返回时可能会导致麻烦。

We regularly have portrait-only apps that show landscape videos via web views.

Are you sure you're returning NO for landscape orientations from your shouldAutorotateToOrientation: method of the top view controller? When you say "goes berserk," what do you mean? One thing I've found is that setting the main window's rootViewController property (rather than just adding your root view controller's view as a subview of the window view) can cause trouble when returning from videos like this.

黯然 2024-12-22 09:58:38

我知道我晚了几个月,但我编写了一个简单的 UINavigationController 子类来正确传递 shouldAutorotateToInterfaceOrientationwillRotateToInterfaceOrientation 和 < code>didRotateFromInterfaceOrientation 调用正确的视图控制器。

希望这有帮助:)

https://gist.github.com/bbae6291c4f6bf05d1eb

I know I'm a few months late, but I've written a simple UINavigationController subclass to properly pass the shouldAutorotateToInterfaceOrientation, willRotateToInterfaceOrientation, and didRotateFromInterfaceOrientation calls through to the proper view controller.

Hope this helps :)

https://gist.github.com/bbae6291c4f6bf05d1eb

沉溺在你眼里的海 2024-12-22 09:58:38

当视频从全屏关闭时,将调用 UIViewController 中的 viewWillAppear: 方法。您可以通过在 UIView 上调用 setNeedsDisplay 来调整视图

The method viewWillAppear: in your UIViewController will be called when the video is closed from full screen. You can adjust the view there by calling setNeedsDisplay on your UIView

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文