开发者

touchesEnded:withEvent: How to work around the delay before it fires

开发者 https://www.devze.com 2023-01-12 02:55 出处:网络
On iPhone OS, -touchesEnded:withEvent: fires quickly when you left a finger, unless there was a drag. If -touchesMoved:withEvent: has fired, then there is about a 0.6 second delay before you get touch

On iPhone OS, -touchesEnded:withEvent: fires quickly when you left a finger, unless there was a drag. If -touchesMoved:withEvent: has fired, then there is about a 0.6 second delay before you get touchesEnded:withEvent:.

I verified this in a new project, no scrollView, no multi-touch.

I want the user to drag an object around, and then have a method 开发者_C百科fire as soon as he lifts a finger. The 0.6 second delay is unacceptable.

Any thoughts on dealing with this?

Edit: The only code I have written in the test project is this:

   @implementation MyView

// startTime is an ivar
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    startTime = [NSDate timeIntervalSinceReferenceDate];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"%f", [NSDate timeIntervalSinceReferenceDate] - startTime);
}


Found the problem: Magic Trackpad. When you run the Simulator, Magic Trackpad adds a delay before it decides that you have ended a touch.

0

精彩评论

暂无评论...
验证码 换一张
取 消