Reputation: 762
I am doing the View resize,move and rotate on single touch.
I am trying to find the touch moved direction like,
IF touch moved direction is Horizontal or Vertical then MOve the view. If touch moved direction is diagonal then resize. And if touch moved like rotate gesture then rotate the View.
I am able to identify the Horizontal or Vertical direction.
Please suggest me how i can identify the diagonal and rotation.
Upvotes: 1
Views: 1314
Reputation: 697
in touch move function, you can identify the direction of move finger like this.
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesMoved:touches withEvent:event];
UITouch *touch = [touches anyObject];
CGPoint current=[touch locationInView:self];
CGPoint last=[touch previousLocationInView:self];
if(current.x>last.x){
NSLog(@">>>>rigth");
}else{
NSLog(@">>>>left");
}
if(current.y>last.y){
NSLog(@">>>>up");
}else{
NSLog(@">>>>down");
}
}
Upvotes: 1
Reputation: 4279
I guess for rotation, you can simply use this mehod -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
.
And for diagonal, you can compare coordinates of both the points. For diagonal, you can take help from this post also.
Upvotes: 1