UIPageViewControllerDelegate:'NSInternalInconsistencyException',原因:'Invalid parameter not satisfying: [views count] == 3'
UIPageViewControllerDelegate: 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: [views count] == 3'
应用程序崩溃并显示错误消息:
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)
}
修复了它在 DispatchQueue.main.async {}
中包装 setViewControllers 方法
应用程序崩溃并显示错误消息:
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)
}
修复了它在 DispatchQueue.main.async {}
中包装 setViewControllers 方法