开发者

UISwipeGestureRecognizer gesture start point

Is it possible to get a gesture start point from a UISwi开发者_Python百科peGestureRecognizer. like how its possible in

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

    UITouch * touch = [touches anyObject];
    gestureStartPoint = [touch locationInView:self];
}


According to the UISwipeGestureRecognizer documentation you can:

You may determine the location where a swipe began by calling the UIGestureRecognizer methods locationInView: and locationOfTouch:inView:. The former method gives you the centroid if more than one touch was involved in the gesture; the latter gives the location of a particular touch.

PS: you really should first look at the documentation, the answer was in the class reference of UISwipeGestureRecognizer, shouldn't be hard to find. Part of being a developer is being able to look things up, Apple has excellent documentation, use it!


WARNING

Amy's answer is totally INCORRECT! Recognizer may generate UIGestureRecognizerStateBegan but on swipe UISwipeGestureRecognizer generates UIGestureRecognizerStateEnded event only.

But touchesBegan: works instead. The problem is if it supports user interaction then it works for current view only and you need to pass it to a parent view.


Yes, it is possible. See code below:

if ([recognizer state] == UIGestureRecognizerStateBegan || [recognizer state] != UIGestureRecognizerStateChanged) {
    NSLog(@"StateBegan :::::");
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜