ataravati
ataravati

Reputation: 9145

Disable zooming on PDFView (iOS)

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
}()

Upvotes: 5

Views: 1838

Answers (1)

Sagar Chauhan
Sagar Chauhan

Reputation: 5823

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
}

Upvotes: 9

Related Questions