UIPageViewController error without stack log
An attempt to implement UIPageViewController
. Let's start by adding one UIViewController
as a page. But the app crashes without a stack log. I don't run into any kind of exception as I have included the exception breakpoints. A similar question was asked here . It doesn't seem to be a problem.
This is all I do:
- (void)viewDidLoad {
[super viewDidLoad];
self.dataSource = self;
self.delegate = self;
// Get all the 3 VCs
self.view.backgroundColor = [UIColor clearColor];
self.matchInfoVC = [[MatchInfoViewController alloc] initWithNibName:@"MatchInfoViewController" bundle:nil];
self.matchInfoVC.index = 1;
UIViewController *initialViewController = (UIViewController*)[self viewControllerAtIndex:0];
NSArray *viewControllers = [NSArray arrayWithObject:initialViewController];
[self setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
}
#pragma mark UIPageViewController Delegates
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
NSUInteger index = [(MatchInfoViewController *)viewController index];
if (index == 0) {
return nil;
}
index--;
return [self viewControllerAtIndex:index];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
NSUInteger index = [(MatchInfoViewController *)viewController index];
index++;
if (index == 2) {
return nil;
}
return [self viewControllerAtIndex:index];
}
- (UIViewController *)viewControllerAtIndex:(NSUInteger)index {
switch (index) {
case 0:{
self.matchInfoVC.index = index;
return self.matchInfoVC;
break;
}
}
return nil;
}
+3
source to share
No one has answered this question yet
See similar questions:
or similar: