开发者

swipe distance in iphone sdk?

Through swipe gesture, is it possible to cal开发者_开发知识库culate the distance of swipe (up, down, left, right)?


- (CGFloat)distanceBetweenTwoPoints:(CGPoint)fromPoint toPoint:(CGPoint)toPoint

{
float x = toPoint.x - fromPoint.x;
float y = toPoint.y - fromPoint.y;
return sqrt(x * x + y * y);
}

Hope its help you, just pass starting and endpoint to this method ....


I've used an approach similar to this article to recognise swipe gestures of a certain number of pixels, but if you're using a base SDK of at least 4 try using UISwipeGestureRecognizer which can make it much easier; see this post.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜