触摸开始和触摸结束之间的时间

Sid*_*qui 3 iphone objective-c

在objective-c中是否有任何方法可以找到触摸开始和触摸结束之间的时间?

wil*_*lc2 19

// add this ivar to your view controller
NSTimeInterval lastTouch;

 // assign the time interval in touchesBegan:
 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
 {
     lastTouch = [event timestamp];
 }  


 // calculate and print interval in touchesEnded:
 -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
{
    NSTimeInterval touchBeginEndInterval = [event timestamp] - lastTouch;

    NSLog(@"touchBeginEndInterval %f", touchBeginEndInterval);
}   
Run Code Online (Sandbox Code Playgroud)