iPhone - Rotate ImageView with 2 Finger Gesture/Pinch

You must Login before you can answer or comment on any questions.

Hiya

I am trying to rotate an imageview by using the 2 finger iphone/ipad rotate gesture but am struggling to work out how. I've seen a few similar questions on here but without a solution or answer.

The imageview is ideally going to be placed within a scrollview if that helps but it can easily not be if needed

I had come across a module on the marketplace called gesture recogniser which sounded like it did the trick but since finding it last week it now seems to be removed :/

https://marketplace.appcelerator.com/http-status/?164337751

I've also found Objective C tutorials and examples - an example: http://iphonedevelopment.blogspot.co.uk/2009/12/better-two-finger-rotate-gesture.html) but this obviously isn't much help unless you know how to create a module from it which i don't :(

In a previous app i used the following code to rotate either clockwise or anti clockwise on a button press, i just now need to do similar but with the touch gesture.

//Define empty click counters for Rotate function
var clicksC = 0;
var clicksA = 0;
 
//Rotate image function
function rotateImage(choice, count){
    var t = Ti.UI.create2DMatrix();
    var spin = Titanium.UI.createAnimation();
    if (choice =='clock'){
        var degrees = (-(clicksA *10))+(clicksC *10);
    }
    else if (choice =='anti'){
        var degrees = (-(clicksA *10))+(clicksC *10);
    }
    t = t.rotate(degrees);
    spin.transform = t;
    image.animate(spin);
}
 
//Rotate Clockwise Button function 
rotateClockBtn.addEventListener('click',function(e){ 
    clicksC = clicksC+1;
    rotateImage('clock',clicksC);
}); 
 
//Rotate Anti-Clockwise Button function 
rotateAntiBtn.addEventListener('click',function(e){ 
    clicksA = clicksA+1;
    rotateImage('anti',clicksA);
});
Hope this isn't too vague but i'm really struggling with this and one of the main functions of the app is to rotate with gestures so i really need to solve it

Thanks in advance

Lauren :)

— asked 9 months ago by Lauren McCold
1 Comment
  • Luckily the module is back in marketplace now so this question is no longer needed :)

    — commented 9 months ago by Lauren McCold

Your Answer

This question has been locked and cannot accept new answers.