Two-finger rotation gesture on the iPhone?

后端 未结 2 1326
逝去的感伤
逝去的感伤 2021-02-04 22:22

I\'m working on an iPhone app with a lot of different gesture inputs that you can do. Currently there is single finger select / drag, two finger scroll, and two finger pinch zoo

2条回答
  •  爱一瞬间的悲伤
    2021-02-04 23:05

    I've done that before by finding the previous and current distances between the two fingers, and the angle between the previous and current lines. Then I picked some empirical thresholds for that distance delta and angle theta, and that has worked out pretty well for me.

    If the distance was greater than my threshold, and the angle was less than my threshold, I scaled the image. Otherwise I rotated it. 2 finger scroll seems easy to distinguish.

    BTW in case you are actually storing the values, the touches have previous point values already stored.

    CGPoint previousPoint1 = [self scalePoint:[touch1 previousLocationInView:nil]];
    CGPoint previousPoint2 = [self scalePoint:[touch2 previousLocationInView:nil]];
    CGPoint currentPoint1 = [self scalePoint:[touch1 locationInView:nil]];
    CGPoint currentPoint2 = [self scalePoint:[touch2 locationInView:nil]];
    

提交回复
热议问题