I'm writing an iPad application that needs to time the finger movement very precisely, so I am keen on getting the best performance and accuracy I can. I have two questions about this:
For intercepting finger position on screen, must I use touchesMoved(), or is there a lower-level API?
Does anyone开发者_如何学Python know whether touchesMoved() returns the exact position on screen, or does the iPad perform some interpolation?
Thanks!
You have 3 ways to intercept finger positions: a) UIResponder Delegate metods:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
b) UIGestureRecognizer's methods
c) You also can override - (void)sendEvent:(UIEvent *)event; within UIApplicationDelegate or UIWindow to catch UIEvents - but this method is not recommended.
All this methods work with UITouch that contain touch point. This point calculated by device hardware, so you can't affect precision.
And the last: minimal recommended touch area is 44x44. If you touch area will be smaller then users will fill yourself discomfortable working with your software.
Touches are not very precise, because fingers are not very precise (much less so than a mouse cursor), and because the tracking hardware isn't very precise (because it doesn't need to, because of finger size - it does not work without significant touched area).
That being said, the iDevices have very good touchscreens compared to many other capacitive touch devices. I'm just not sure pixel-precision is attainable in practice.
It's easy to experiment with this, though.
精彩评论