检查 UIAlertView 是否可见
我有一种情况,我想弹出一个警报视图,但显示警报视图的事件可能每 5 秒发生一次。我不想有一堆警报视图供用户单击“确定”,所以我想知道。
如何检查 UIAlertView 当前是否正在显示?
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.
How do you check if a UIAlertView is currently showing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以保留对它的引用,也可以在警报委托中设置一个标志。当您打开警报时,将标志设置为 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.