0

Im am trying to learn swift and I am stuck trying to display pdf file from local url. I have set contentView which has pdfView on it. all is okay but the pdf is not scrollable. I would be happy if someone could help me. This is my code:

private func pdf()
{
    guard let path = Bundle.main.url(forResource: "example", withExtension: "pdf") else { return }

    let pdfView = PDFView()

    contentView.addSubview(pdfView)

    titleLabel.text = "PDF View"

    guard let pdfDocument = PDFDocument(url: path) else { return }
    pdfView.document = pdfDocument

    pdfView.frame = contentView.bounds
    pdfView.autoScales = true
    pdfView.displayMode = .singlePageContinuous
    pdfView.displayDirection = .horizontal
    pdfView.usePageViewController(true, withViewOptions: nil)
}
user12723399
  • 127
  • 1
  • 1
  • 5

0 Answers0