Disabling user interaction of all types except one

I am trying to simulate the behavior of a UIAlertView. Basically, I want to present a view and disable the interaction of users of all other types on the screen (in addition to the presented view). How can i do this?

+4
source share
3 answers

Your warning should consist of two views. The first is the screen size and userInteractionEnabled set to YES . This prevents any touching of the views from below. Then you add as a sub-view of this view your actual warning window with any buttons, etc. that you like.

You can include both of them in the new UIWindow , which you can set for windowLevel to make sure they are on top of everything else on the screen.

You can also add a very minor backgroundColor to the screen size, which obscures everything behind it if it suits your interface.

+10
source

I would recommend adding a view (with user interaction disabled) with a black background with alpha 0.3 to the main application window when you show your custom warning. This, in addition to preventing user interaction, also adds a subtle dimming effect to the user interface behind your user view.

+1
source

Call [view setUserInteractionEnabled:NO] for all views for which you want to disable user interaction. Remember to call [view setUserInteractionEnabled:YES]; again [view setUserInteractionEnabled:YES]; before you release your own warning.

0
source

All Articles