Check if a UIAlertView is visible

混江龙づ霸主 提交于 2019-12-11 11:27:21

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/1861369/check-if-a-uialertview-is-visible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!