Reputation: 415
After rearranging the structure of my UIViews I seem to have introduced a delay in drawing (users can draw on the screen with their finger). Before the onset of drawing was negligible, but now there is a noticeable latency between the initial movement of the finger and the drawing of the line. As I keep drawing the latency seems to disappear. So it is possible the initial touch event is delayed somewhere.
My question is not how to solve this specific instance, but in the diagnosis I ran into the following question: What is the earliest point I can register the (time of onset of the) touch of the screen?
Now I put timestamps in hitTest in all the UIResponders (UIWindow -> UIView -> ... -> DrawingView). But could there be delays before the first call to hitTest in UIWindow?
Thanks!
Upvotes: 0
Views: 118
Reputation: 385600
UIWindow
delivers touch events to gesture recognizers before delivering the events directly to views. This happens inside -[UIWindow sendEvent:]
(https://developer.apple.com/documentation/uikit/uiwindow/1621614-sendevent). I believe it hit-tests the view hierarchy to find the gesture recognizers that might be interested in the event, so you should not expect the hitTest:withEvent:
messages to be delayed.
If there is a gesture recognizer on your view or any of its superviews, that gesture recognizer can delay the delivery of touch events.
Note that many of UIKit's standard views use gesture recognizers. In particular, UIScrollView
uses gesture recognizers that can delay touch events, and both UITableView
and UICollectionView
are subclasses of UIScrollView
.
Upvotes: 2