我有一个页面视图控制器,但我收到了错误Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: [views count] == 3'
这是我的数据源:
//
// MSABDrawingPageModelController.m
// My Special Alphabet Book
//
// Created by Ari Porad on 9/3/13.
// Copyright (c) 2013 Cari Books. All rights reserved.
//
#import "MSABDrawingPageModelController.h"
#import "MSABDrawingViewController.h"
#import "MSABDrawingView.h"
@implementation MSABDrawingPageModelController
-(id)initWithLetter:(MSABLetter *)letter{
if (self = [super init]) {
self.letter = letter;
}
return self;
}
-(id)init{
return [self initWithLetter:nil];
}
-(NSURL *)docsDirUrl{
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] objectAtIndex:0];
}
-(UIViewController *)viewControllerAtIndex:(int)index{
MSABDrawingViewController *VC = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"MSAB_DRAWING_VIEW_CONTROLLER"];
((MSABDrawingView *) VC.view).points = [NSMutableArray arrayWithArray:@[[NSMutableArray array]]];
VC.index = index;
VC.letter = self.letter;
return VC;
}
#pragma mark -
#pragma mark Page View Controller Data Source Methods
-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController{
UIViewController *vc = [self viewControllerAtIndex:((MSABDrawingViewController *)viewController).index + 1];
if(vc == nil){
vc = [[MSABDrawingViewController alloc] init];
}
NSLog(@"AVC: %@", vc);
return vc;
}
-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController{
UIViewController *vc = [self viewControllerAtIndex:((MSABDrawingViewController *)viewController).index - 1];
if(vc == nil){
vc = [[MSABDrawingViewController alloc] init];
}
NSLog(@"PVC: %@", vc);
return vc;
}
@end
让我知道您是否还有其他需要知道的。