title: uiscrollview zoom in and zoom out doesn't work properly
body: <p>I have a uiscrollview and there is a uiimageview inside it. I want the used to be able to zoom in out of the image since it's a big image. the scrollview only needs to scroll vertically not horizontally. </p>
  
  <p>before adding the zooming effect I had the following code and it worked as I wanted,</p>
  
  <pre><code>-(void)viewDidLoad
  {
  [scrollView setScrollEnabled:YES];
  [scrollView setContentSize:CGSizeMake(320, 1690)];
  }
  </code></pre>
  
  <p>So I did some research and ended up with the following code to enable pinch zoom in and out,</p>
  
  <pre><code>-(void)viewDidLoad
  {
  scrollView.scrollEnabled = YES;
  
  [scrollView setContentSize:CGSizeMake(320, 1690)];
  scrollView.delegate = self;
  //    scrollView.contentSize = instImage.frame.size;
  scrollView.minimumZoomScale = scrollView.frame.size.width / instImage.frame.size.width;
  scrollView.maximumZoomScale = 2.0;
  [scrollView setZoomScale:scrollView.minimumZoomScale];
  [[NSRunLoop currentRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate distantFuture]];
  
   }
  
  
   - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
  
  return instImage;
  }
  
  
   - (CGRect)centeredFrameForScrollView:(UIScrollView *)scroll andUIView:(UIView *)rView {
  
  CGSize boundsSize = scroll.bounds.size;
  CGRect frameToCenter = rView.frame;
  
  // center horizontally
  if (frameToCenter.size.width &lt; boundsSize.width) {
  
      frameToCenter.origin.x = ((boundsSize.width - frameToCenter.size.width) / 2);
  
  }else {
  
      frameToCenter.origin.x = 0;
   }
  
  return frameToCenter;
   }
  
  
   - (void)scrollViewDidZoom:(UIScrollView *)scrollV {
  
  instImage.frame = [self centeredFrameForScrollView:scrollV andUIView:instImage];;
   }
  </code></pre>
  
  <p>Now I have the following problems and I can't figure out what's wrong,</p>
  
  <ol>
  <li><p>when the view is just loaded before any pinch the scrollview doesn't scroll all the way to the end of the image.</p></li>
  <li><p>when pinched to zoom in, it scrolls left and right and up and down the image, but still it doesn't scroll down all the way to the end of the image, but still more than what it originally did at the begining. </p></li>
  <li><p>when I zoom out, the whole thing stops. you can't zoom in or out, it doesn't even scroll anymore. totally locked. </p></li>
  </ol>
  
  <p>I did some reseach and found the following post. 
  <a href="https://stackoverflow.com/a/6384834/1103257">https://stackoverflow.com/a/6384834/1103257</a></p>
  
  <p>but I don't know where would I find NSDefaultRunLoopMode  or even how to search for it to figure out whether this can solve it or not. </p>