尝试实施UIPageViewController
。首先只需添加一个UIViewController
作为页面。但是应用程序在没有堆栈日志的情况下崩溃。我没有遇到任何异常,因为我已经启用了异常断点。类似的问题被问到here。似乎没有解决问题。
这就是我所做的一切:
- (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;
}