如何在iPhone中阻止UI [英] How to block UI in IPhone

查看:83
本文介绍了如何在iPhone中阻止UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不使用睡眠的情况下阻止UI线程?

How can I block UI thread without using sleep?

请明确一点:我知道用户界面将冻结,但这就是这个主意.

Just to be clear: I understand that UI will freeze for user, but that is the idea.

我可以运行空的RunLoops吗?任何其他方式.

Can I run empty RunLoops? Any other ways.

推荐答案

如果只想阻止与UI的所有交互,请调用UIApplication方法-beginIgnoringInteractionEvents.如果您实际上是在尝试阻止整个UI进行任何操作(这不是一个好主意,例如您的应用程序可能会阻止系统通知的出现),那么可以,NSRunLoop可能是正确的方法

If you just want to block all interaction with your UI, call the UIApplication method -beginIgnoringInteractionEvents. If you're actually trying to prevent the entire UI from doing anything (which is not a good idea—your application might block the appearance of a system notification, for instance), then yes, an NSRunLoop would probably be the right approach.

这篇关于如何在iPhone中阻止UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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