如何观察 UIAlertView 何时显示? [英] How to observe when a UIAlertView is displayed?

查看:31
本文介绍了如何观察 UIAlertView 何时显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何都可以观察是否正在显示 UIAlertView 并在显示时调用函数.

Is it anyway possible to observe if a UIAlertView is being displayed and call a function when it is.

UIAlertView 没有在我想要调用函数的同一个类中创建和显示.

The UIAlertView is not being created and displayed in the same class which I want a function to be called in.

这很难解释,但简单地说,我需要以某种方式监控或观察视图是否变得像第一响应者或其他东西,因为我认为无法监控 UIAlertView 是否正在显示:/

Its hard to explain but to put it simply I need to somehow monitor or observe if the view becomes like out of first responder or something because I dont think it is possible to monitor if a UIAlertView is being displayed :/

推荐答案

听起来像是通知的工作.

Sounds like a job for notifications.

假设 A 类创建了 UIAlert,B 类需要观察它.A 类定义了通知.B 类注册该通知.当 A 班打开警报时,它会发布通知,B 班将自动看到它.

Say that class A creates the UIAlert and class B needs to observe it. Class A defines a notification. Class B registers for that notification. When Class A opens the alert it post the notification and class B will see it automatically.

有关详细信息,请参阅 NSNotification.

See NSNotification for details.

这篇关于如何观察 UIAlertView 何时显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆