检查UIAlertView是否可见 [英] Check if a UIAlertView is visible

查看:57
本文介绍了检查UIAlertView是否可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种情况,我想弹出一个警报视图,但是显示警报视图的事件可能每5秒发生一次.我希望没有一堆警报视图供用户单击确定",所以我很想知道.

I have a situation where I would like to pop up an alert view, but the event that shows the alert view could occur as often as every 5 seconds. I'd rather not have a stack of alert views for the user to click OK on so I was wondering.

如何检查UIAlertView当前是否显示?

How do you check if a UIAlertView is currently showing?

推荐答案

您可以保留对其的引用,也可以在警报委托中设置标志.当您打开警报时,将标志设置为true,并在警报调用其解雇委托函数时将其翻转为false.检查该标志的状态,以确定当前是否打开警报.

You could retain a reference to it or you could set a flag in your alert delegate. When you open the alert set the flag to true and when the alert calls its dismissal delegate function flip it to false. Check the state of the flag to determine whether an alert is currently open.

如果您认为甚至有可能最终会收到一堆警报,则可能需要重新考虑您的设计.您的用户将不喜欢在警告对话框之后被警告对话框击中.

If you think it even possible you could end up with a stack of alerts you might want to rethink your design. Your users will not like being hit with alert dialog after alert dialog.

这篇关于检查UIAlertView是否可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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