关于来自UITapGestureRecognizer的消息 [英] About messages from UITapGestureRecognizer

查看:75
本文介绍了关于来自UITapGestureRecognizer的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是来自文档:


虽然点击是离散手势,但它们对于手势识别器的每个状态都是离散的;因此,当手势开始时发送相关联的动作消息,并且针对每个中间状态发送相关动作消息,直到(并且包括)手势的结束状态。


上述段落似乎表明发送了多条消息。消息将包括开始消息和结束消息。但不知何故,我只是得到了手势结束的消息。有什么方法可以同时获得点击开始和结束消息吗? (我想跟踪的是 - 开始:用户触摸屏幕并结束的那一刻:用户将手指从屏幕上抬起的那一刻。)



<希望知识渊博的人可以提供帮助...



http://developer.apple.com/library/ios/#documentation/UIKit/Reference /UITapGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/cl/UITapGestureRecognizer

解决方案

   - (void)touchesBegan:(NSSet *)触及withEvent:(UIEvent *)事件{

NSDate * date1 = [NSDate date]; //用户触摸屏幕


}

- (void)touchesEnded:(NSSet *)触及withEvent:(UIEvent *)事件{

NSDate * date2 = [NSDate date]; //用户将手指抬离屏幕

}


The following is from documentation :

Although taps are discrete gestures, they are discrete for each state of the gesture recognizer; thus the associated action message is sent when the gesture begins and is sent for each intermediate state until (and including) the ending state of the gesture.

The above passage seems to indicate that more than one message is sent. The messages would include a "begin" message and an "end" message. But somehow I just get the "gesture end" message. Is there any way I can get both the tap begin and end message ? (What I wish to track is - "begin" : the moment the user touches the screen and "end" : the moment the user lifts his finger away from the screen.)

Hope that somebody who is knowledgable on this could help ...

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITapGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/cl/UITapGestureRecognizer

解决方案

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

      NSDate *date1 = [NSDate date]; //user touches the screen


}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{

      NSDate *date2 = [NSDate date];  //user lifts his finger away from the screen

}

这篇关于关于来自UITapGestureRecognizer的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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