아래 처럼 죽는 경우가 발생
2017-02-22 13:29:28.984 PageTest[87046:5081125] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The number of view controllers provided (3) doesn't match the number required (1) for the requested transition'
* 원인
setViewControllers([vc1, vc2, vc3], direction: .forward, animated: false, completion: nil)
첫 번째 인자에 필요이상의 뷰컨트롤러를 할당함
* 수정
setViewControllers([vc1], direction: .forward, animated: false, completion: nil)
vc1만 할당 하고 나머지는 DataSource에서 처리 하도록 함
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
guard let index = vcs.index(of: viewController)
else { return nil }
if index < 1 {
return nil
} else {
return vcs[index - 1]
}
}
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
guard let index = vcs.index(of: viewController)
else { return nil }
if index + 1 >= vcs.count {
return nil
} else {
return vcs[index + 1]
}
}
댓글 없음:
댓글 쓰기