I am trying to disable the TouchesEnded event in my Code when someone clicks on a button. And when the user clicks on another button the TouchesEnded should be activated again.
So for understanding what my app does, every time you click on the screen the text on the screen changes. But when the user clicks the Button a, this touch event should be disabled. And when the user clicks on button b it should be activated again.
i have already tried self.view.isUserInteractionEnabled = false
, but then I am not able to click on the button to activate the userInteraction again.
Does anybody as an idea how to fix this problem?
From the behavior you're describing, I'm assuming that your button is a subview of the view that's toggling isUserInteractionEnabled
? Setting that flag to false will prevent user interaction on the view's subviews as well. You can fix this by adjusting the view hierarchy so that your button and your self.view
are siblings: aka create a container view that has both the button and your referenced self.view
as children.