title: UIScrollView zoomToRect not zooming to given rect (created from UITouch CGPoint)
body: <p>My application has a UIScrollView with one subview. The subview is an extended UIView which prints a PDF page to itself using layers in the drawLayer event.</p>
  
  <p>Zooming using the built in pinching works great. setZoomScale also works as expected.</p>
  
  <p>I have been struggling with the zoomToRect function. I found an example online which makes a CGRect zoomRect variable from a given CGPoint. </p>
  
  <p>In the touchesEnded function, if there was a double tap and they are all the way zoomed out, I want to zoom in to that PDFUIView I created as though they were pinching out with the center of the pinch where they double tapped.</p>
  
  <p>So assume that I pass the UITouch variable to my function which utilizes zoomToRect if they double tap.</p>
  
  <p>I started with the following function I found on apples site:</p>
  
  <p><a href="http://developer.apple.com/iphone/library/documentation/WindowsViews/Conceptual/UIScrollView_pg/ZoomZoom/ZoomZoom.html" rel="noreferrer">http://developer.apple.com/iphone/library/documentation/WindowsViews/Conceptual/UIScrollView_pg/ZoomZoom/ZoomZoom.html</a></p>
  
  <p>The following is a modified version for my UIScrollView extended class:</p>
  
  <pre><code>- (void)zoomToCenter:(float)scale withCenter:(CGPoint)center {     
  
      CGRect zoomRect;
      zoomRect.size.height = self.frame.size.height / scale;
      zoomRect.size.width  = self.frame.size.width  / scale;
  
      zoomRect.origin.x = center.x - (zoomRect.size.width  / 2.0);
      zoomRect.origin.y = center.y - (zoomRect.size.height / 2.0); 
  
      //return zoomRect;
  
      [self zoomToRect:zoomRect animated:YES];
  
  } 
  </code></pre>
  
  <p>When I do this, the UIScrollView seems to zoom using the bottom right edge of the zoomRect above and not the center.</p>
  
  <p>If I make UIView like this</p>
  
  <pre><code>UIView *v = [[UIView alloc] initWithFrame:zoomRect]; 
  [v setBackgroundColor:[UIView redColor]];
  [self addSubview:v];
  </code></pre>
  
  <p>The red box shows up with the touch point dead in the center.</p>
  
  <p>Please note: I am writing this from my PC, I recall messing around with the divided by two part on my Mac, so just assume that this draws a rect with the touch point in the center. If the UIView drew off center but zoomed to the right spot it would be all good.</p>
  
  <p>However, what happens is when it preforms the zoomToRect it seems to use the bottom right off the zoomRect at the top left of the zoomed in results.</p>
  
  <p>Also, I noticed that depending on where I click on the UIScrollView, it anchors to diffrent spots. It almost seems like there is a cross down the middle and it's reflecting the points somehow as though anywhere left of the middle is a negative reflection and anywhere right of the middle is a positive reflection?</p>
  
  <p>This seems to complicated, shouldn't it just zoom to the rect that was drawn as the UIView was able to draw?</p>
  
  <p>I used a lot of research to figure out how to create a PDF that scales in high quality, so I am assuming that using the CALayer may be throwing off the coordinate system? But to the UIScrollView it should just treat it as a view with 768x985 dimensions. </p>
  
  <p>This is sort of advanced, please assume the code for creating the zoomRect is all good. There is something deeper with the CALayer in the UIView which is in  the UIScrollView....</p>