I have a UIImageView, which I want to be able to resize and rotate etc.
Can a GestureRecognizer be added to the ImageView?
I would want to add a rotate and pinch recognizer to a UIImageView which would be created at runtime.
How does one add these recognizers?
Thanks
Source: Tips4all
Check that userInteractionEnabled is YES on the UIImageView. Then you can add a gesture recognizer.
ReplyDeleteimageView.userInteractionEnabled = YES;
UIPinchGestureRecognizer *pgr = [[UIPinchGestureRecognizer alloc]
initWithTarget:self action:@selector(handlePinch:)];
pgr.delegate = self;
[imageView addGestureRecognizer:pgr];
[pgr release];
:
:
- (void)handlePinch:(UIPinchGestureRecognizer *)pinchGestureRecognizer
{
//handle pinch...
}