我收到以下错误:
*由于未捕获的异常'NSInvalidArgumentException'而终止应用,原因:'*
- [__ NSArrayM insertObject:atIndex:]:object不能为nil'
这是我的代码:
UIViewController *p1 = [storyboard instantiateViewControllerWithIdentifier:@"First"];
NSLog(@" p1 %@",p1);
UIViewController *p2 = [storyboard
instantiateViewControllerWithIdentifier:@"Second"];
UIViewController *p3 = [storyboard
instantiateViewControllerWithIdentifier:@"Third"];
UIViewController *p4 = [storyboard
instantiateViewControllerWithIdentifier:@"Fourth"];
_Array = @[p1,p2,p3,p4];
NSLog(@"%@",_Array);
self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PageViewController"];
self.pageViewController.dataSource = self;
self.pageViewController.delegate = self;
[[self.pageViewController view] setFrame:CGRectMake(0, 0, 320, 500)];
[_pageViewController setViewControllers:@[p1]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];
[self.pageViewController willMoveToParentViewController:self];
[self addChildViewController:_pageViewController];
[self.view addSubview:_pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];