Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How are touch events handled in a uiview?


Asked by Harmony Sandoval on Dec 13, 2021 FAQ



UIViews can handle touch events in two ways. Developers use the high-level gesture recognizer API to detect and handle gestures, or roll their own event handling by using the low-level interface that provides detailed touch events as they happen: every time a finger touches the screen or is lifted as well as motion of those fingers.
Accordingly,
However, if you use custom views to display your content, you must handle all touch events that occur in your views. There are two ways to handle touch events yourself. Use gesture recognizers to track the touches; see Handling UIKit Gestures. Track the touches directly in your UIView subclass; see Handling Touches in Your View.
And, For example, to handle touch events, a responder implements the touchesBegan (_:with:), touchesMoved (_:with:), touchesEnded (_:with:), and touchesCancelled (_:with:) methods. In the case of touches, the responder uses the event information provided by UIKit to track changes to those touches and to update the app's interface appropriately.
In this manner,
They handle input through Mouse Events (mouseup, mousedown, mousemove & other mouse events). Web applications wanting to handle mobile devices use Touch Events (touchstart, touchup, touchmove). But in addition to handling touch, they must handle mouse input as well.
Just so,
For touch events, consistency implies that pointers go down one at a time, move around as a group and then go up one at a time or are canceled. While the framework tries to deliver consistent streams of motion events to views, it cannot guarantee it.