title: UIGestureRecognizer ending
body: <p>I would like to handle the rotation gesture in my iPhone app and rotate an imageView during this. At the end of the gesture I would like to rotate to a fix position the imageView.
  So ie. if I rotate the imageView from 0 radian to M_PI/2 radians, but somewhere on halfway I end with the gesture. After the end I would like to test the angle and if it close to M_PI/2 then set it to M_PI/2 otherwise to 0.<br>
  Here's my code how I tried to do this:  </p>
  
  <p>I create and add the recognizer to my view.</p>
  
  <pre><code>UIGestureRecognizer *recognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(gestureRecognized:)];
  recognizer.delegate = self;
  [self addGestureRecognizer:recognizer];
  [recognizer release];
  </code></pre>
  
  <p>Delegate methods:</p>
  
  <pre><code>- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
      if (_imageView) {
          return YES;
      }
      return NO;
  }
  
  - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
      return YES;
  }
  </code></pre>
  
  <p>Gesture recognized method:</p>
  
  <pre><code>- (void)gestureRecognized:(UIRotationGestureRecognizer *)recognizer {
      _imageView.transform = CGAffineTransformMakeRotation(recognizer.rotation);
  }
  </code></pre>
  
  <p>These methods are working, but here's the method how I tried to get the end of the gesture. This is not working:</p>
  
  <pre><code>- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
      NSLog(@"gesture end");
  }
  </code></pre>
  
  <p>Also with the transform I have a little problem. Sometimes it is going back to the 0 radian.</p>
  
  <p>Any suggestion is welcome. Thanks!</p>