我正在为 iPad 制作电子书。这本书的每一页都是应用程序 StoryBoard 中的一个视图控制器,它们的页码在 Interface Builder 中设置为它们的标识符。我正在研究实现导航的类,其作用是呈现和关闭视图控制器。它通过在呈现的视图控制器上覆盖一组按钮并处理它们的 IBAction 来实现。
我的问题是某些视图控制器(偶数页)从未出现过!谁能明白为什么?
@implementation Navigator
UIViewController *currentPageVC;
UIViewController *nextPageVC;
int currentPage = 0;
-(void)viewDidLoad{
[self getLandingPage];
}
-(void)getLandingPage{
currentPageVC = [self.storyboard instantiateViewControllerWithIdentifier:@"Landing"];
currentPage = 0;
NSLog(@"Trying to present landing page");
}
-(IBAction)goToNextPage{
[currentPageVC dismissModalViewControllerAnimated:YES];
currentPage++;
nextPageVC = [self.storyboard instantiateViewControllerWithIdentifier:[NSString stringWithFormat:@"%d", currentPage ]];
[self presentModalViewController:nextPageVC animated:YES];
[nextPageVC.view addSubview:self.view];
currentPageVC = nextPageVC;
NSLog(@"Current Page is %d", currentPage);
}