Could someone guide in what I need to do? I need to attach a pan gesture recognizer to an image which rotate clockwise and anticlockwise as we move.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’ll want to attach a
UIPanGestureRecognizerto the image and when the action method is called you can ask for the current translation and velocity of the gesture. You’d then rotate the image according to these values. Since this is a continuous gesture you’ll be notified when the pan gesture changes, allowing you to update the rotation of the image.UIPanGestureRecognizer Class Reference
—
Update
I’ve reread your question and if you want to rotate the image with your fingers by doing the typical rotate gesture, you should use the
UIRotationGestureRecognizerinstead of theUIPanGestureRecognizer. If you want to do a pan gesture moving your fingers left or right, you’ll indeed have to use aUIPanGestureRecognizer. I just wanted to complete the answer.Adding the rotation gesture recognizer:
Handling the gesture and rotating the image accordingly could look like this (in its simplest form):