Documentation of UIControl Class:
What is the difference between UIControlEventTouchDragInside
, UIControlEventTouchDragEnter
, UIControlEventTouchUpInside
? All seem to be the same.
Documentation of UIControl Class:
What is the difference between UIControlEventTouchDragInside
, UIControlEventTouchDragEnter
, UIControlEventTouchUpInside
? All seem to be the same.
No, those all are not same. Though they are all coming from UIControl
.
Apple made this things available inside a struct
for swift and for Objective-C its available inside an enum
. Both of this are inside UIControlEvents
. Following are the struct
& enum
which you may look.
struct UIControlEvents : OptionSetType { //This is for Swift.
init(rawValue rawValue: UInt)
static var TouchDown: UIControlEvents { get }
static var TouchDownRepeat: UIControlEvents { get }
static var TouchDragInside: UIControlEvents { get }
static var TouchDragOutside: UIControlEvents { get }
static var TouchDragEnter: UIControlEvents { get }
static var TouchDragExit: UIControlEvents { get }
static var TouchUpInside: UIControlEvents { get }
static var TouchUpOutside: UIControlEvents { get }
static var TouchCancel: UIControlEvents { get }
static var ValueChanged: UIControlEvents { get }
static var PrimaryActionTriggered: UIControlEvents { get }
static var EditingDidBegin: UIControlEvents { get }
static var EditingChanged: UIControlEvents { get }
static var EditingDidEnd: UIControlEvents { get }
static var EditingDidEndOnExit: UIControlEvents { get }
static var AllTouchEvents: UIControlEvents { get }
static var AllEditingEvents: UIControlEvents { get }
static var ApplicationReserved: UIControlEvents { get }
static var SystemReserved: UIControlEvents { get }
static var AllEvents: UIControlEvents { get }
}
typedef enum UIControlEvents : NSUInteger { //This is for Objective-C.
UIControlEventTouchDown = 1 << 0,
UIControlEventTouchDownRepeat = 1 << 1,
UIControlEventTouchDragInside = 1 << 2,
UIControlEventTouchDragOutside = 1 << 3,
UIControlEventTouchDragEnter = 1 << 4,
UIControlEventTouchDragExit = 1 << 5,
UIControlEventTouchUpInside = 1 << 6,
UIControlEventTouchUpOutside = 1 << 7,
UIControlEventTouchCancel = 1 << 8,
UIControlEventValueChanged = 1 << 12,
UIControlEventPrimaryActionTriggered = 1 << 13,
UIControlEventEditingDidBegin = 1 << 16,
UIControlEventEditingChanged = 1 << 17,
UIControlEventEditingDidEnd = 1 << 18,
UIControlEventEditingDidEndOnExit = 1 << 19,
UIControlEventAllTouchEvents = 0x00000FFF,
UIControlEventAllEditingEvents = 0x000F0000,
UIControlEventApplicationReserved = 0x0F000000,
UIControlEventSystemReserved = 0xF0000000,
UIControlEventAllEvents = 0xFFFFFFFF
} UIControlEvents;
Now coming to the theoretical explanation which apple does for this things separately. BTW I am not explaining all the events but taking your requirements only.
UIControlEventTouchDragEnter
- An event where a finger is dragged into the bounds of the control.(I hope you know the difference between frames
and bounds
)
UIControlEventTouchDragInside
- An event where a finger is dragged inside the bounds of the control.
UIControlEventTouchUpInside
- A touch-up event in the control where the finger is inside the bounds of the control.
This are all available from iOS 2.0 onwards. See the difference between TouchUp
and TouchDrag
also which will help you to get a clear idea about this things.
Thanks, Hope this helped.