Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable zooming on PDFView (iOS)

Tags:

ios

swift

pdfview

How can I disable zooming on PDFView?

I've already tried the solution here, but it didn't work. I can still zoom in and zoom out.

Here's my PDFView:

let pdfView: PDFView = {
    let pdfView = PDFVIew()
    let urlPath = Bundle.main.path(forResource: "PdfFile", ofType: "pdf")
    let url = URL(fileURLWithPath: urlPath!)
    pdfView.document = PDFDocument(url: url)
    pdfView.autoScales = true
    pdfView.displayMode = .singlePageContinuous
    pdfView.displayDirection = .vertical
    pdfView.pageShadowsEnabled = false
    return pdfView
}()
like image 776
ataravati Avatar asked Sep 06 '19 18:09

ataravati


1 Answers

Add following line of code will disable zoom of PDFView.

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    pdfView.minScaleFactor = pdfView.scaleFactor
    pdfView.maxScaleFactor = pdfView.scaleFactor
}
like image 110
Sagar Chauhan Avatar answered Sep 26 '22 05:09

Sagar Chauhan