Monday, April 16, 2012

GestureRecognizer on UIImageView


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

1 comment:

  1. Check that userInteractionEnabled is YES on the UIImageView. Then you can add a gesture recognizer.

    imageView.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...
    }

    ReplyDelete