开发者

About messages from UITapGestureRecognizer

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 the开发者_运维问答re 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


The UITapGestureRecognizer only fires when the gesture state is UIGestureRecognizerStateEnded

If you want to use a gesture recogniser to detect the start and end of a press, use the UILongPressGestureRecognizer, with the minumumPressDuration set to 0


- (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

}


Why don't you use - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event method ?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜