我知道还有其他几个这样的问题,但我无法找到解决问题的方法.我使用了一个显示不同ViewControllers的pageViewController.每次pageViewController向前移动时,我都会检查lastPage的输入.如果错误,pageViewController应该使用setViewController方法返回到该页面.没有这个方法一切正常,但如果我尝试使用它,应用程序崩溃与以下异常:
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'
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
- (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
{ …Run Code Online (Sandbox Code Playgroud) 我的应用程序包含UIPageViewController中嵌入的UITableViewController,不时会引发此异常:
Invalid parameter not satisfying: [views count] == 3
Run Code Online (Sandbox Code Playgroud)
回溯:
* thread #1: tid = 0x6239fa, 0x03d1d88a libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread, stop reason = breakpoint 25.3
frame #0: 0x03d1d88a libobjc.A.dylib`objc_exception_throw
frame #1: 0x0404f448 CoreFoundation`+[NSException raise:format:arguments:] + 136
frame #2: 0x03428fee Foundation`-[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
frame #3: 0x01e7c535 UIKit`-[_UIQueuingScrollView _replaceViews:updatingContents:adjustContentInsets:animated:] + 185
frame #4: 0x01e800ca UIKit`-[_UIQueuingScrollView _didScrollWithAnimation:force:] + 1231
frame #5: 0x01e7bb57 UIKit`-[_UIQueuingScrollView _scrollViewAnimationEnded:finished:] + 104
frame #6: 0x0190583c UIKit`-[UIScrollView(UIScrollViewInternal) animator:stopAnimation:fraction:] + 62
frame #7: 0x0197096e UIKit`-[UIAnimator stopAnimation:] + 533
frame …Run Code Online (Sandbox Code Playgroud)