UIButton events. What's the difference?

I ran into a problem when my button should remain “pressed” while a popover is displayed on it. Popover is a filter selector, and the filter is displayed on the button itself. When I click on it and it shows a popover, it becomes unselected no matter what.

I think that I need to redefine its behavior on the touch event and make it respond non-standardly touch up inside . Then I wondered what other events are responsible for. But I could not find the list of events in the iOS library, and in StackOverflow there were only questions about the incorrect behavior of touch up inside or touch down .

So what is the difference between touch events?

  • touch cancel - when the button is pressed, but release your finger and it is not canceled?
  • Touch down - right when pressed.
  • Touch down repeat ??
  • touch drag enter
  • drag and drop contact
  • drag a tattoo inside?
  • touch drag out ???
  • touch inside - when you press and release the button remaining in it. It changes the state of UIButtons to Normal.
  • touch out - when you press and release the button, leaving its borders?

other IBActions are not sent to UIButton, right? Also, how do these events change the look of UIButton? How highlighted or selected ?

I would appreciate a link to a good article on IBActions, because I could not find it.

+56
ios objective-c uibutton ibaction
Jul 09 '12 at 6:20
source share
2 answers

From Apple UIControlEvents for UIControlEvents :

  1. UIControlEventTouchCancel

    A system event that undoes current touches for a control.

  2. UIControlEventTouchDown

    Touch event in the control.

  3. UIControlEventTouchDownRepeat

    Repeated touch in the control; for this event, the value of the tapCount UITouch method is greater than one.

  4. UIControlEventTouchDragEnter

    An event when a finger is dragged within the control.

  5. UIControlEventTouchDragExit

    An event when a finger is dragged from the inside of a control beyond its bounds.

  6. UIControlEventTouchDragInside

    The event when the finger is dragged outside the control.

  7. UIControlEventTouchDragOutside

    The event when the finger is dragged outside the control.

  8. UIControlEventTouchUpInside

    Touch event in the control when the finger is within the control.

  9. UIControlEventTouchUpOutside

    Touch event in the control when the finger is outside the control.

+136
Jul 09 '12 at 6:30
source share

The general use order / probability of occurrence for a normal button is listed, as I consider it:

UIControlEventTouchDown : user clicked a button. This works when a finger / stylus contacts.

UIControlEventTouchUpInside : user clicked a button. This is triggered by a finger / stylus contact pushed back from the screen.




Useful for sliders and drag and drop events such as moving a component. The following are listed in order of appearance:

UIControlEventTouchDragInside : Fires when you drag your finger to the button area.

UIControlEventTouchDragExit : Fires during a drag motion. It is called only once, since the user's finger / stylus extends beyond the button.

UIControlEventTouchDragOutside : Fires during a drag movement after 'UIControlEventTouchDragExit' and is called continuously while the initial touch continues.

UIControlEventTouchUpOutside : This is just a tap of a finger / stylus, BUT only if the finger / stylus is no longer within the button. The important thing (and probably obvious) that needs to be called is that the touch had to be inside the button at some point in order to associate this event with the button.

Note: I understand that the above may be useful for:

  1. Sliders: as you would expect, touching might be deliberate, but due to the quick action of the finger, the movement of their fingers may be inaccurate and rise beyond the area of ​​the slider.
  2. Moving components, for example, when you move objects around the screen, you want the movement to occur when the finger / stylus touches the border of the component / object.



Other events:

UIControlEventTouchCancel : Something from the user control cancels the touch action. Think of it as something “wrong” on the phone side.

UIControlEventTouchDownRepeat : Want to determine when your user is angry and furiously clicks a button? Want to determine if they are in Windows mode and trying to double-click? Or maybe you designed a button to do something else if they click twice. This event helps with all this!




Recommendations:

SO 1 : difference between UIControlEventTouchDragOutside and UIControlEventTouchDragExit

SO 2 : What is a UIControlEventTouchCancel?

0
Apr 28 '19 at 23:42 on
source share



All Articles