触摸开始到触摸结束之间的时间 [英] Time between touch began and touch ended

查看:71
本文介绍了触摸开始到触摸结束之间的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is there any method in objective-c to find the time between touch began and touch ended??

推荐答案

// 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);
}   

这篇关于触摸开始到触摸结束之间的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆