从 UIWebView 打开媒体播放器时通知?

Notified when media player opens from UIWebView?(从 UIWebView 打开媒体播放器时通知?)

本文介绍了从 UIWebView 打开媒体播放器时通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用中有一个 UIViewController,其中有一个 UIWebView.UIWebView 是固定大小的,并配置为在新的 UIViewController(浏览器)中打开任何链接.这可行,但是当我尝试从 Web 视图中单击 YouTube 或 Vimeo 等视频时,它会在视图控制器顶部打开.这通常不会成为问题,但我有一个重叠的视图,需要在发生这种情况时收到一条消息才能让开.

I have got a UIViewController in my app with a UIWebView in it. The UIWebView is fixed-size and configured to open any links in a new UIViewController (browser). This works, but when I try clicking a video like YouTube or Vimeo from within the web view, it opens on top of the view controller. This would normally not be a problem, but I have an overlapping view that needs to get a message to move out of the way when this happens.

当媒体播放器从 UIWebView 中弹出时,是否有通知或任何其他方式可以通知我的视图控制器?我真的需要这个更好地工作,因为它现在的样子真的很丑.

Is there a notification or any other way my view controller can get notified when a media player pops out of the UIWebView? I really need this to work better, because it's really ugly the way it currently is.

谢谢!

推荐答案

来自:http://www.alexcurylo.com/blog/2009/08/24/snippet-playing-youtube-videos/

不幸的是,没有直接控制或加载、进度、退出等通知.但是,您可以根据应用程序的窗口状态获得一些间接通知:添加到您的视图控制器中

Unfortunately, there’s no kind of direct control or notifications of loading, progress, quitting, etc. However, you can get some indirect notifications based on your application’s window state: add in your view controller

[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(windowNowVisible:)
name:UIWindowDidBecomeVisibleNotification
object:self.view.window
];

[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(windowNowHidden:)
name:UIWindowDidBecomeHiddenNotification
object:self.view.window
];

在 YouTube 窗口显示和消失时分别调用它们.

to get these called when the YouTube window is shown and goes away respectively.

- (void)windowNowVisible:(NSNotification *)notification
{
   NSLog(@"Youtube/ Media window appears");
}


- (void)windowNowHidden:(NSNotification *)notification 
{
   NSLog(@"Youtube/ Media window disappears."); 
}

嘿,如果这就是你所需要的通知方式,那就太好了!

and hey, if that’s all you require by way of notification you’re good!

这篇关于从 UIWebView 打开媒体播放器时通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:从 UIWebView 打开媒体播放器时通知?

基础教程推荐