Drag and Drop in UIButtons

I have four UIButtons on a UIView in an iPad application that is being developed for iPad Simulator 3.2.

This is currently happening: the user drags his finger from one button to another. When the finger leaves the first button, this button remains active, and nothing happens when the finger passes over the second button, if the user does not release the touch and again does not press the screen on the second button.

I need that, at the moment when their finger leaves the area of ​​the first UIButton, it must return to its default UI state, and when the finger enters the area of ​​the second UIButton, the second button must accept its active state and fire the event.

I really lost completely how to do this, I did a lot of Googling, nothing offered a quick solution to what seems to me to be something that should be easy to accomplish.

Thanks in advance.

+3
source share
2 answers

Look at changing the actions of your button to use one of the many available control events available . Namely, it sounds as if you need to register your buttons to perform actions on UIControlEventTouchDragEnter and / or UIControlEventTouchDragExit.

+1
source

, , UIButtons . . X Y .

UIButtons .

+1

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


All Articles