pan gesture after rotation behaves incorrect
Asked Answered
S

2

7

I have similar question as in below link

Why I use "pan" after rotae will make view go opposite way?

But, this link also didn't solved my problem. I am using pan, pinch and rotation gesture for same UIImage. When, i rotate that image, and performs pan, it will give random panning(sometimes it goes in opposite direction of panning. I also set anchor point to (0.5,0.5)). But, if i only use pan (i.e. before rotation) it will perform well as expected. How can i resolve this issue?

Syllabogram answered 21/9, 2012 at 7:21 Comment(3)
good question, I sadly have the same problem. Did you have any solution?Falsework
Not yet. Even i tried pan via touches move but still it behaves incorrect after using rotate gesture on same image.Syllabogram
ok if I find the solution, I will post it here. Therefore I took this question as favorite, so I will find it then.Falsework
S
8

Finally solved this issue... You just need to change below code CGPoint translation = [gesture translationInView:gesture.view];to CGPoint translation = [gesture translationInView:[gesture.view superview]]; present inside UIPanGestureRecognizer method.

OR follow below link http://cs354dory.wordpress.com/code-examples/pinch-pan-and-rotate/

Syllabogram answered 6/11, 2012 at 11:2 Comment(2)
same effect like my code :) I checked your code, too. Nice and finally we both found the solution :)Falsework
wowowowowowowowowowowowowoowowowowowow thank UUUuuuuuuuUUUUu !!!!!!!!!!!!!! i have same problem for a long time. my stress reach the climax....! your angel !!!! thank youHelicopter
F
1

I solved it,too.

Just put these 2 lines of code into the rotationfunction.

gestureRecognizer.view.transform = CGAffineTransformRotate(gestureRecognizer.view.transform, gestureRecognizer.rotation);
gestureRecognizer.rotation = 0;
Falsework answered 6/11, 2012 at 14:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.