禁用屏幕上当前视图的用户交互 [英] Disabling user interaction of the current view on screen
问题描述
我的应用程式有许多资料检视和各自的控制器。现在我有一组模型类,其中有业务逻辑。其中一个模型类(NSObject的子类)负责管理安全性。它的目的函数是监听来自web服务器的特定指令,并且如果从服务器到达禁用消息,则禁用UI以用于任何进一步的使用。
My app has many views and their respective controllers. Now I have a set of model classes with business logic in them. One of the model classes(subclass of NSObject) has the responsibility of managing security. It's intended function is to listen for a particular instruction from a web server and if a 'disable' message arrives from server, disable the UI for any further usage.
现在禁用消息可以在应用程序运行期间的任何时刻到达,并且任何视图都可以在屏幕上可见。如何确定哪些视图对用户可见(来自我的模型类),并为其禁用用户互动?
Now the 'disable' message can arrive at any instant during the functioning of the app and any view can be visible on screen. How do I determine which view is visible to the user(from my model class) and disable user interaction for it?
推荐答案
你希望整个应用程序根本不反应?
Maybe you want the whole application to not react at all?
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
使用 [[UIApplication sharedApplication] endIgnoringInteractionEvents];
将此
(学分转换为nerith)
use [[UIApplication sharedApplication] endIgnoringInteractionEvents];
to revert this
(credits to nerith)
这篇关于禁用屏幕上当前视图的用户交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!