How to make pdfView zoom=100% to fit screen size

So I have this pdfView and I wanna make it so its first display is a zoom of 100% of the page, but the problem is that what I have now is zooming in to much and the UI is not pretty to be like that. It just like zooms to much and I want it to be perfectly zoomed to fit the screen size.
I have tried and can't find a solution.

My code is this:

Code Block let pdfView = PDFView()
pdfView.translatesAutoresizingMaskIntoConstraints = false
pdfView.autoScales = true
pdfView.maxScaleFactor = 4.0
pdfView.minScaleFactor = pdfView.scaleFactorForSizeToFit
view.addSubview(pdfView)
pdfView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true
pdfView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true
pdfView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
pdfView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true
guard let path = Bundle.main.url(forResource: materia , withExtension: "pdf") else { return }
if let document = PDFDocument(url: path) {
pdfView.document = document
}


Hi there,

You have to put PDFView setters after setting PDFDocument and it will all should be working.

pdfView.translatesAutoresizingMaskIntoConstraints = false	
view.addSubview(pdfView)		

pdfView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true		pdfView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true		pdfView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true		pdfView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true						

guard let path = Bundle.main.url(forResource: materia , withExtension: "pdf") else { return }		
if let document = PDFDocument(url: path) {				
    pdfView.document = document		
    pdfView.autoScales = true		
    pdfView.maxScaleFactor = 4.0		
    pdfView.minScaleFactor = pdfView.scaleFactorForSizeToFit	
}
How to make pdfView zoom=100% to fit screen size
 
 
Q