Passage of sensory events

I have a working UIButton in the view controller view.

I have an instance of UIView on top of a button (I will call it topView) in the same controller view. If the condition is met, I will forward all touch events (started, moved, completed, canceled) in the nextResponder view.

But when the condition is triggered, the button does not accept the event. If I move the topView so that it is not above the button, the button works (or sets the userInteractionEnabled property to false). If topView is above the button, the button does not work. So disappointing that I see a button under the guise!

Do I need to do anything in the view controller to receive touch events from sending them to the next responder?

I read all the documents I can use in the defendant chain, but I'm still a little confused.

+4
source share
1 answer

The next element of the view is either its view controller or its supervisor. UIButton in your setup is nothing, so it does not accept events.

In this situation, instead of forwarding events to the next responder, you must override pointInside:withEvent: to return NO. Thus, the system will act in the same way as your opinion. According to the documentation, you can also set userInteractionEnabled to NO in your view with the same effect.

+6
source

Source: https://habr.com/ru/post/1341745/


All Articles