title: UIPageViewController with different ViewControllers, right way?
body: <p>Basically, I have a Table View Controller and a normal View Controller, I want to make it so that I can swipe between the view controllers like on the home screen of app (obvious same type of view controller).</p>
  
  <p>But the thing I am finding is that the <code>UIpageviewcontroller</code> is usaully used when you have multiple views of the same type of <code>viewcontroller</code> for example swiping between pictures, you could just set an index in the class and an array of images relating to the index and set it up that way. </p>
  
  <p>But I'm trying to get different view controllers in this set up. Right now it's two but will definitely go up to about 4. </p>
  
  <p>Is <code>UIPageViewController</code> the right way to set it up or something else.</p>
  
  <p>EDIT: Code added below</p>
  
  <pre><code>    //
  //  ViewController.m
  //  testb
  //
  #import "MainPostController.h"
  #import "MainTableViewController.h"
  #import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  @synthesize pageViewController;
  @synthesize indexValue = _indexValue;
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      self.indexValue= 1;
      NSLog(@"main intitated");
  
      // Do any additional setup after loading the view, typically from a nib.
      self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PageViewController"];
      self.pageViewController.dataSource = self;
  
      MainTableViewController *tvc = [self.storyboard instantiateViewControllerWithIdentifier:@"MainTableViewController"];
      MainPostController *pvc;
      NSArray *viewcontrollers =[NSArray arrayWithObjects:tvc, pvc, nil];
  
      [self.pageViewController setViewControllers:viewcontrollers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
  
      self.pageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 30);
  
      [self addChildViewController:pageViewController];
      [self.view addSubview:pageViewController.view];
      [self.pageViewController didMoveToParentViewController:self];
  }
  
  - (void)didReceiveMemoryWarning
  {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
  }
  
  
  
  
  -(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
  {
      if (self.indexValue == 1) {
          MainPostController *pvc = [self.storyboard instantiateViewControllerWithIdentifier:@"MainPostController"];
          self.indexValue = 0 ;
          return  pvc;
  
      }
      else return nil;
  
  
  
  
  }
  
  -(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
  {
  
      if (self.indexValue == 0) {
          MainTableViewController *tvc = [self.storyboard instantiateViewControllerWithIdentifier:@"MainTableViewController"];
          self.indexValue = 1;
          return tvc;
  
      }
      else return nil;
  
  
  }
  @end
  </code></pre>
  
  <p>I want the intial view to be the table view controller(tvc) and i want the Post view controller(pvc) to be to its left. I can load it up and swipe between the two easily but sometime i can swipe further than the boundaries so basically if i start on the tvc-->pvc-->tvc then i can go further by swiping right to the same tvc then the boundary is reached or go the other way tvc-->pvc-->tvc-->pvc-->pvc by swiping left for the last transition. The boundaries are reached in the end. Once the app intially launches at tvc i cannot go forward a page, (which is what should happen) and if i go tvc-->pvc and try to go to a page to the left it wont let me (which is what should happen)</p>
  
  <p>Thanks</p>