Notified when media player opens from 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 打开媒体播放器时通知?


- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01