App crashes with the error message:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: [views count] == 3'
private func rotateFirstPage() {
guard let pageViewController = pageViewController else {
return
}
if let firstPage = pageDataSource.pages.first {
pageViewController.setViewControllers([firstPage], direction: .forward, animated: true, completion: nil)
}
}
func pageViewController(_ pageViewController: UIPageViewController,
didFinishAnimating finished: Bool,
previousViewControllers: [UIViewController],
transitionCompleted completed: Bool) {
if firstAutoRotation {
Timer?.invalidate()
rotateFirstPage()
}
pageControl.currentPage = pageDataSource.presentationIndex(for: pageViewController)
}
fixed it wrapping setViewControllers method in DispatchQueue.main.async {}