Skip to content

Instantly share code, notes, and snippets.

@ahmedk92
Created July 18, 2019 16:10
Show Gist options
  • Select an option

  • Save ahmedk92/0180d6ae484fa4e25468ed0b52a8abbf to your computer and use it in GitHub Desktop.

Select an option

Save ahmedk92/0180d6ae484fa4e25468ed0b52a8abbf to your computer and use it in GitHub Desktop.
UIPageViewController setViewControllers not calling dataSource methods fix
class PageViewController: UIPageViewController {
override func setViewControllers(_ viewControllers: [UIViewController]?, direction: UIPageViewController.NavigationDirection, animated: Bool, completion: ((Bool) -> Void)? = nil) {
super.setViewControllers(viewControllers, direction: direction, animated: animated) { (isFinished) in
if isFinished && animated {
DispatchQueue.main.async {
super.setViewControllers(viewControllers, direction: direction, animated: false, completion: nil)
}
}
completion?(isFinished)
}
}
}
@ahmedk92
Copy link
Author

Just wrapped this solution in a subclass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment