LoginSignup
0
2

【Swift】PDFViewで前後のページに移動する

Last updated at Posted at 2021-11-29

SwiftのPDFKitで前後のページに移動する方法。

PDFKitの導入

設定画面のGeneralのFrameworks,Libraries, and Embedded ContentのプラスボタンからPDFKit.frameworkを追加。

コードで実装する際は以下の通り。

let pdfView = PDFView()

pdfView.frame = CGRect(x: 0, y: 0, width: view.bounds.width, height: view.bounds.height)
pdfView.autoScales = true
pdfView.displayMode = .singlePage
pdfView.displayDirection = .horizontal
pdfView.displaysPageBreaks = true
pdfView.usePageViewController(true)

各プロパティの詳細は以下をご覧ください。

前後のページに移動

PDFViewで前後のページに移動する際は以下の処理。

//前のページに戻る
pdfView.goToPreviousPage(self)
//後のページに進む
pdfView.goToNextPage(self)

参考

https://qiita.com/taketomato/items/8102a80cd4ce516523de
https://dev.classmethod.jp/articles/ios-11-pdfkit/

Swiftのお役立ち情報

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2