So, after long games, I got him to work, sort of like I imagined. It has no transitions at the moment, but I wanted to publish code to be viewed by others.
In the storyboard, I have a view controller for the entire game, which has a presentation container and a button. The view built into the game view is a page controller that will contain different types of questions. Then the non-attached in the storyboard are different types of question layouts, in my case the Display command and the locationDisplay command.
In QuestionViewController, I added two properties to the .h file:
@property (nonatomic, strong) UIPageViewController *pageViewController; @property (nonatomic, strong) NSMutableArray *questionTypeViewControllers;
Method declared:
-(void)changeView;
In the .m file, they were synthesized:
@synthesize questionTypeViewControllers, pageViewController;
In the viewDidLoad method:
pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil]; UIViewController *ldvc = [self.storyboard instantiateViewControllerWithIdentifier:@"locationDisplay"]; UIViewController *tdvc = [self.storyboard instantiateViewControllerWithIdentifier:@"teamDisplay"]; questionTypeViewControllers = [NSMutableArray arrayWithObjects:ldvc, tdvc, nil]; NSArray *initView = [NSArray arrayWithObject:ldvc]; [pageViewController setViewControllers:initView direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil]; [self addChildViewController:pageViewController]; [self.view addSubview:self.pageViewController.view];
And then the changeView method is implemented:
NSArray *initView = [NSArray arrayWithObject: [questionTypeViewControllers objectAtIndex:1]]; [pageViewController setViewControllers:initView direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
In the GameViewController where the button is located, add an action to the button and call the newly created changeView method from QuestionViewController.
- (IBAction)change:(id)sender {
And it's all. No problem?;)
I have no idea if this is suitable for this, but it worked. Any suggestions or improvements are welcome.