Detect when a webview video becomes fullscreen on ios8(检测 webview 视频何时在 ios8 上变为全屏)
问题描述
我有一个应用程序,用户可以在其中打开 UIWebview 的视频,包括 Youtube 视频.在 iOS7 中,我能够在开始播放或全屏播放时收到通知,这对我向用户显示某些选项和修改界面至关重要.
I have an app where users can open videos from UIWebview, including Youtube ones. In iOS7, I was able to get a notification when it started playing, or when it became full screen, which is vital for me to show certain options to the user and modify the interface.
我以前用这个:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(VideoExitFullScreen:) name:@"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(VideoEnterFullScreen:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
但是,从 iOS8 开始,我无法做到这一点.就像 UIWebview 视频不再触发通知一样.但是,正如我测试过的,它仍然是由普通视频、非 Webview 触发的.
However, since iOS8, I can't achieve this. It is like the notification is no longer triggered from UIWebview videos. However, it is still triggered from normal videos, non-Webview, as I've tested.
知道发生了什么变化吗?
Any idea of what have changed?
推荐答案
这是我找到的解决方法..
This is the work around I found for this..
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(VideoExitFullScreen:)
name:UIWindowDidBecomeVisibleNotification
object:self.view.window];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(VideoEnterFullScreen:)
name:UIWindowDidBecomeHiddenNotification
object:self.view.window];
这篇关于检测 webview 视频何时在 ios8 上变为全屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:检测 webview 视频何时在 ios8 上变为全屏
基础教程推荐
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01