Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marlonjames71/f58f63a63db45abe16a60999d5609c42 to your computer and use it in GitHub Desktop.
Save marlonjames71/f58f63a63db45abe16a60999d5609c42 to your computer and use it in GitHub Desktop.
extension PagedMediaViewController: UIPageViewControllerDelegate {
func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
guard
let mediaVCs = pageViewController.viewControllers as? [MediaViewController],
let currIndex = mediaItems.firstIndex(of: mediaVCs[0].mediaItem)
else { return }
currentIndex = currIndex
}
// If you want to specify the interface orientations you want to support, implement these as well:
func pageViewControllerSupportedInterfaceOrientation(_ pageViewController: UIPageViewController) -> UIInterfaceOrientationMask {
// example
.allButUpsideDown
}
func pageViewControllerPreferredInterfaceOrientationForPresentation(_ pageViewController: UIPageViewController) -> UIInterfaceOrientationMask {
// example
.portrait
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment