ios PDFKit displaymode = singlepage only shows the first page of the pdf

前端 未结 3 1452
囚心锁ツ
囚心锁ツ 2021-01-20 10:15

I\'m trying to display a pdf on ios via apples PDFKit library, and rather than use PDFDisplayMode.singlePageContinuous mode, I want to stop at page breaks so I\'m trying to

3条回答
  •  长情又很酷
    2021-01-20 10:52

    A another simple way to do this is setting

    pdfView.usePageViewController(true) 
    

    This adds the swiping between pages for you and no need to set up your own gestures. See example below:

    override func viewDidLoad() {
        super.viewDidLoad()
    
        // Add PDFView to view controller.
        let pdfView = PDFView(frame: self.view.bounds)
        self.view.addSubview(pdfView)
    
        // Configure PDFView to be one page at a time swiping horizontally
        pdfView.autoScales = true
        pdfView.displayMode = .singlePage
        pdfView.displayDirection = .horizontal
        pdfView.usePageViewController(true)
    
        // load PDF
        let webUrl: URL! = URL(string: url)
        pdfView.document = PDFDocument(url: webUrl!)
    }
    

提交回复
热议问题