Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I found the solution.</p> <p>The problem was when you create a <code>UIScrollView</code> programmatically it sets <code>minimumZoomScale</code> and <code>maximumZoomScale</code> 1.0 by default. So actually my code was working but I didn't know that it was working because it wasn't zooming in or zooming out.</p> <p>So I added two lines to my code and it worked !!! Here is the changes in my code</p> <pre><code>PDFScrollView *pageViewer = [[PDFScrollView alloc] initWithFrame:frame]; pageViewer.minimumZoomScale = 0.2; pageViewer.maximumZoomScale = 5.0; [self.scrollviewer addSubview:pageViewer]; </code></pre> <p>When I inserted two lines it worked but I was able to zoom in or zoom out infinitely. I wanted to zoom at max scale of 5. So I changed <code>scrollViewDidEndZooming</code> method given in the file <code>PDFScrollView.m</code></p> <p>Default code shipped with Apple's <code>ZoomingPDFViewer</code> looks like this:</p> <pre><code>// Set the new scale factor for the TiledPDFView. _PDFScale *= scale; // Calculate the new frame for the new TiledPDFView. CGRect pageRect = CGPDFPageGetBoxRect(_PDFPage, kCGPDFMediaBox); pageRect.size = CGSizeMake(pageRect.size.width*_PDFScale, pageRect.size.height*_PDFScale); </code></pre> <p>After changes it looks like:</p> <pre><code>// Set the new scale factor for the TiledPDFView. _PDFScale *= scale; self.minimumZoomScale *= 1 / scale; self.maximumZoomScale *= 1 / scale; // Calculate the new frame for the new TiledPDFView. CGRect pageRect = CGPDFPageGetBoxRect(_PDFPage, kCGPDFMediaBox); pageRect.size = CGSizeMake(pageRect.size.width*_PDFScale, pageRect.size.height*_PDFScale); </code></pre> <p>Now it works.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload