在iOS 8之前,只要媒体播放器从UIWebView进入全屏,就会发送UIMoviePlayerControllerDidEnterFullscreenNotification通知.在iOS 8中,这不会发生,有些人建议改为监听AVPlayerItemBecameCurrentNotification通知.这似乎不是从WKWebView发送的.侦听UIWindowDidBecomeVisibleNotification通知不起作用,因为它被添加到所有添加的窗口(包括广告网络等)
@H_403_2@最重要的是,我整晚都在努力,我似乎无法弄清楚如何使用WKWebView全屏打开视频.任何帮助,将不胜感激.
@H_403_2@编辑:为了确认,我创建了一个空白项目.添加了一个UIWebView和AVPlayerItemBecameCurrentNotification监听器,当我播放视频并进入全屏时它被触发.我将UIWebView切换到WKWebView,并且不再触发该通知.
解决方法
这种解决方法似乎适用于iOS8& iPhone 6
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowBecameHidden:) name:UIWindowDidBecomeHiddenNotification object:nil]; return TRUE; } - (void)windowBecameHidden:(NSNotification *)notification { UIWindow *window = notification.object; if (window != self.window) { // Not my own window: assuming the video window was hidden,maybe add some more checks here. // Add code here } }