I am trying to implement a UIPageViewController
. I have done this before but using the same UIViewController
and changing the images etc when paging. I want to page between different UIViewController
now. I'm trying to code the method that creates the UIViewController
based on what is in an array that contains the storyboard ID for the UIViewControllers
. For example I have this array:
self.controllerIdentifiers=[NSArray arrayWithObjects:@"ViewControllerTypeA",@"ViewControllerTypeB", nil];
Now trying to implement :
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{
if (self.controllerIndex==0) return nil;
self.controllerIndex--;
NSString *id = self.controllerIdentifiers[self.controllerIndex];
//If I knew the controller type I would do something like this..
ViewControllerTypeA *typeA = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewControllerTypeA"];
return typeA;
}
The problem is I'm not sure how to tell the code what type of UIViewController
it is. Do I need to case some logic for every possible index and just initiate a UIViewController
that way?