LoginSignup
1
2

More than 5 years have passed since last update.

iOS11でPageViewControllerの現在のページが取れない時の対処法

Posted at

以前は pageViewController.childViewControllers.first で現在のページがとれていたと思うのですが、iOS11.1 でとれなくてはまりました。

一応、対処法を見つけたのでメモしておきます。

    func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {

        DispatchQueue.main.async {
            if !completed { return }

            let currentVC = pageViewController.childViewControllers.filter {
                !previousViewControllers.contains($0)
            }.first

            // currentVCつかった処理をかく
        }
    }
1
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
1
2