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 上变为全屏
基础教程推荐
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
