Swiftワン・ピース・コード:PageViewControllerで使ってみる(3)

こんにちは。川上です。
前々回からのPageViewControllerの続きです。
StoryBoardで作っていた
・MovieMakerVwController
・MovieMakerPageVwController
のControllerの接続と安易なページ設定処理の諸々。。
ページ送りの処理です。
MovieMakerVwControllerに「<」・「>」Buttonを貼り付けて、event処理です。
var pageViewController:UIPageViewController? //MARK: - ⚡️- -- 順方向にページ送りする @IBAction func eventPageLeft(_ sender: Any) { if self.curPage + 1 >= pageVwCount { return } self.curPage += 1; pageViewController!.setViewControllers([vcArray[self.curPage]], direction: .forward, animated: true, completion: nil) } //MARK: - ⚡️- -- 逆方向にページ送りする @IBAction func eventPageRight(_ sender: Any) { if self.curPage - 1 < 0 { return } self.curPage -= 1; pageViewController!.setViewControllers([vcArray[self.curPage]], direction: .reverse, animated: true, completion: nil) }
各MovieMakerPageVwControllerに表示用データの設定に追記します。
class MovieMakerPageVwController: UIViewController { @IBOutlet weak var lblPageNum: UILabel! //表示用Label var curPageNum = 1 //カレントページ override func viewDidLoad() { super.viewDidLoad() lblPageNum.text = String(format: "- %d -",curPageNum ) // Do any additional setup after loading the view. } }
ページ送りで、ページ番号の表示ができました。
各ページ番号の処理に、先に記載していたWebViewを縦書きTypeで使うと、
なんとなく、文庫みたいな感じみたいよな?
BGMや挿絵を組み込みできたら、より面白くなりそうな気がするよね。。
ではでは。