Hello all, I want to rotate the uiimageview also scale the image view so how do i detect touch gesture that user is scaling or user is rotating?
+1
A:
Beginning in iOS 3.2, Apple introduced the use of UIGestureRecognizer
's. The two that you would be interested in are UIPinchGestureRecognizer
and UIRotationGestureRecognizer
. To use a pinch gesture you could do the following:
- (void)viewDidLoad {
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)];
[imageView addGestureRecognizer:pinch];
[pinch release];
}
- (void)handlePinchGesture:(UIGestureRecognizer *)sender {
NSLog(@"New Scale: %f", sender.scale);
}
You could do something similar for the UIRotationGestureRecognizer
then.
rickharrison
2010-07-12 17:04:12
how do i scale imageview? i mean how do i get points?
Rahul Vyas
2010-07-13 06:51:34
NSLog(@"New Scale: %f", sender.scale); It's also gives error while compiling like this "error: request for member 'scale' in something not a structure or union"
Rahul Vyas
2010-07-13 06:56:34
@rickharrisonI want to do it without using UIGestureRecognizer is there a way to do both on touchMoved?
Rahul Vyas
2010-07-13 10:32:36
You can do it in touchMoved, but it will be more complicated. You will need to get the locations of the touch and create a bounding box for those touches. Then you can scale the image view based on that bounding rectangle.
rickharrison
2010-07-13 12:56:32
could you please tell me how it can be done? it might be complicated but it's not impossible....
Rahul Vyas
2010-07-14 09:58:17