Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pan gesture after rotation behaves incorrect

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?

like image 736
stack Avatar asked Sep 21 '12 07:09

stack


2 Answers

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/

like image 95
stack Avatar answered Sep 24 '22 14:09

stack


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;
like image 35
Studie Avatar answered Sep 23 '22 14:09

Studie