title: UIImageView Gestures (Zoom, Rotate) Question
body: <p>I would like to make 2 operations to an <code>UIImageView</code> zoom, rotate, I have 2 problems:</p>
  <blockquote>
  <p><strong>A.</strong> I make an operation for zoom for ex. and when I try to make rotation the <code>UIImageView</code> is set to initial size, I would like to know how to keep the zoomed <code>UIImageView</code> and make the rotation from the zoomed image.</p>
  <p><strong>B.</strong> I would like to combine the zoom operation with rotation and I don't know ho to implement this:</p>
  </blockquote>
  <pre><code>- (void)viewDidLoad 
  {
      foo = [[UIImageView alloc]initWithFrame:CGRectMake(100.0, 100.0, 600, 800.0)];
      foo.userInteractionEnabled = YES;
      foo.multipleTouchEnabled  = YES;
      foo.image = [UIImage imageNamed:@&quot;earth.jpg&quot;];
      foo.contentMode = UIViewContentModeScaleAspectFit;
      foo.clipsToBounds = YES;
      
      [self.view addSubview:foo];
  }
  
  //---pinch gesture--- 
  UIPinchGestureRecognizer *pinchGesture =
  [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)];
  [foo addGestureRecognizer:pinchGesture]; 
  [pinchGesture release];
  
  //---rotate gesture--- 
  UIRotationGestureRecognizer *rotateGesture =
  [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(handleRotateGesture:)];
  [foo addGestureRecognizer:rotateGesture]; 
  [rotateGesture release];
  
  //---handle pinch gesture--- 
  -(IBAction) handlePinchGesture:(UIGestureRecognizer *) sender {
      NSLog(@&quot;Pinch&quot;);
      CGFloat factor = [(UIPinchGestureRecognizer *) sender scale];
      if (factor &gt; 1) { 
          //---zooming in--- 
          sender.view.transform = CGAffineTransformMakeScale(
                                                             lastScaleFactor + (factor-1),
                                                             lastScaleFactor + (factor-1)); 
      } 
      else {
          //---zooming out--- 
          sender.view.transform = CGAffineTransformMakeScale(lastScaleFactor * factor, lastScaleFactor * factor);
      }
      if (sender.state == UIGestureRecognizerStateEnded) { 
          if (factor &gt; 1) {
              lastScaleFactor += (factor-1); 
          } else {
              lastScaleFactor *= factor;
          }
      }
  }
  
  //---handle rotate gesture--- 
  -(IBAction) handleRotateGesture:(UIGestureRecognizer *) sender {
      CGFloat rotation = [(UIRotationGestureRecognizer *) sender rotation]; 
      CGAffineTransform transform = CGAffineTransformMakeRotation(rotation + netRotation); 
      sender.view.transform = transform;
      if (sender.state == UIGestureRecognizerStateEnded) { 
          netRotation += rotation;
      }
  }
  </code></pre>
  <p>Thanks</p>