I want to have just what I receive after
pdfView.autoScales = true
without the possibility to change the scale.
After the help of @carmine we have:
import UIKit
import PDFKit
class ViewController: UIViewController {
@IBOutlet weak var pdfView: PDFView!
override func viewDidLoad() {
super.viewDidLoad()
setPdfFile()
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
self.pdfView.autoScales = true
}
func setPdfFile() {
if let path = Bundle.main.path(forResource: "Swift.org - Getting Started", ofType: "pdf") {
let url = URL(fileURLWithPath: path)
if let pdfDocument = PDFDocument(url: url) {
pdfView.autoScales = true
pdfView.displayMode = .singlePageContinuous
pdfView.displayDirection = .vertical
pdfView.document = pdfDocument
pdfView.displaysPageBreaks = false
pdfView.minScaleFactor = pdfView.scaleFactor
pdfView.maxScaleFactor = pdfView.scaleFactorForSizeToFit
}
}
}
}
This gives such a result: https://gfycat.com/briefpowerlessbug
But if you run without these lines:
pdfView.minScaleFactor = pdfView.scaleFactor
pdfView.maxScaleFactor = pdfView.scaleFactorForSizeToFit
You'll receive the result I need but with zooming: https://gfycat.com/presentconcretebunting
I want to disable zooming and make pdfView's width equal to pdf-file's width.