I know that there are several other questions like this, but i couldn't find a solution for my problem.
I use a pageViewController which displays different ViewControllers. Every time the pageViewController moves forward I check the input of the lastPage. If it's wrong the pageViewController should go back to that page by using the setViewController method. Without this method everything works fine but if I try to use it the app crashes with the following exception:
19:48:25.596 Phook[23579:60b] *** Assertion failure in -[_UIQueuingScrollView _replaceViews:updatingContents:adjustContentInsets:animated:], /SourceCache/UIKit_Sim/UIKit-2935.137/_UIQueuingScrollView.m:383
2014-06-02 19:48:25.600 Phook[23579:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: [views count] == 3'
And here's my code:
- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished
previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed
{
if (completed && finished)
{
RegisterUserPageContent* lastPage = (RegisterUserPageContent*)previousViewControllers[ previousViewControllers.count-1];
int lastIndex = lastPage.pageIndex;
int newIndex = ((RegisterUserPageContent*)[self.pageViewController.viewControllers objectAtIndex:0]).pageIndex;
if (newIndex > lastIndex)
{ // Moved Forward
if(!lastPage.testInput)
{
[self.pageViewController setViewControllers:@[ [self.storyboard instantiateViewControllerWithIdentifier:_pageStoryBoardIDs[0]] ]
direction:UIPageViewControllerNavigationDirectionReverse
animated:YES completion:nil];
}
}
else
{ // Moved Reverse
}
}
}
As I already said. I searched a lot and implemented some solutions but nothing helped.
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…