Basically, I have a Table View Controller and a regular View Controller, I want to make it so that I can scroll between view controllers, for example, on the main application screen (obviously, the same type of controller).
But what I find is that UIpageviewcontrollerusaully is used, when you have several views of the same type viewcontroller, for example, scrolling between images, you can just set the index in the class and the image array related to the index, and configure him that way.
But I'm trying to get different view controllers in this setting. Now it’s two, but it will certainly reach 4.
Is the UIpageviewcontrollerright way to customize it or something else.
EDIT: code added below
#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");
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];
}
-(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
I want the intial view to be the table view controller (tvc), and I want the Post view controller (pvc) to be on its left. I can download it and scroll between the two easily, but someday I can move beyond the borders, so if I start with tvc → pvc → tvc, then I can go further by checking directly to the same TV, then the border is reached or goes another way tvc → pvc → tvc → pvc → pvc, scrolling left for the last transition. Boundaries are reached at the end. When the application starts in tvc, I cannot advance the page (which is what should happen), and if I go tvc → pvc and try to go to the page on the left, this will not allow me (which is what should happen)
thanks