1
Answer

How to create a page slider having 3 view controllers in it.

I need help with ios proramming using objective C.
 
 
I m creating page slider using page view controller but when i click on second VC when the program is running it crashes after the second VC so i dont know how to manage that .
I want 3 view controllers under that page view controller or if it doesnt crash then i get repetitive view controllers in it ,this is my second view controller code
 
 

- (void)viewDidLoad

{

PagedImageScrollView *pageScrollView = [[PagedImageScrollView alloc] initWithFrame:CGRectMake(0, 32, 320, 165)];

[pageScrollView setScrollViewContents:@[[UIImage imageNamed:@"slider1"], [UIImage imageNamed:@"slider2"],[UIImage imageNamed:@"slider3"]]];

pageScrollView.pageControlPos = PageControlPositionCenterBottom;

[self.view addSubview:pageScrollView];

pageScrollView.delegate1 = self;

self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PageViewController"];

self.pageViewController.dataSource = self;


PageContentViewController *startingViewController = [self secondviewcontrollerAtIndex:0];

//secondviewcontroller *startingViewController = [self secondviewcontrollerAtIndex:0];

//

NSArray *viewControllers = @[startingViewController];

[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

// PageContentViewController2 *startingViewController2 = [self secondviewcontrollerAtIndex:0];

//

// NSArray *viewControllers2 = @[startingViewController2];

//

//

// [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

// [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

//

// Change the size of page view controller

self.pageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height + 40);

[self addChildViewController:_pageViewController];

[self.view addSubview:_pageViewController.view];

[self.pageViewController didMoveToParentViewController:self];


}

- (IBAction)buttonLeague:(id)sender {

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

LeaguesViewController* Leagues = [storyboard instantiateViewControllerWithIdentifier:@"Leagues"];

// Leagues.imageFile = @"slider1";

[self presentViewController:Leagues animated:YES completion:nil];

}


- (IBAction)sportsBtn:(id)sender {

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

LeaguesViewController* Leagues = [storyboard instantiateViewControllerWithIdentifier:@"Leagues"];

// Leagues.imageFile = @"slider1";

Leagues.navTitle = @"sports";

Leagues.pageName = @"second";

[self presentViewController:Leagues animated:YES completion:nil];

}



- (IBAction)Event:(id)sender {

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

LeaguesViewController* Leagues = [storyboard instantiateViewControllerWithIdentifier:@"Leagues"];

// Leagues.imageFile = @"slider1";

Leagues.navTitle = @"event";

Leagues.pageName = @"second";

[self presentViewController:Leagues animated:YES completion:nil];

}


- (IBAction)Location:(id)sender {

}


- (IBAction)MenuClicked:(id)sender {

[self.view endEditing:YES];

[self.frostedViewController.view endEditing:YES];

// Present the view controller

//

[self.frostedViewController presentMenuViewController];

}


- (IBAction)Tournament:(id)sender {

}




-(void)buttonWasPressed

{


NSLog(@"First image tapped");

}




- (IBAction)startWalkthrough:(id)sender {

}





- (PageContentViewController *)secondviewcontrollerAtIndex:(NSUInteger)index

{

// if (([self.pageTitles count] == 0) || (index >= [self.pageTitles count])) {

PageContentViewController *pageContentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PageContentViewController"];

// pageContentViewController.imageFile = self.pageImages[index];

// pageContentViewController.titleText = self.pageTitles[index];

pageContentViewController.pageIndex = index;

return pageContentViewController;

}


#pragma mark - Page View Controller Data Source


- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)secondviewcontroller

{

NSUInteger index = ((PageContentViewController*) secondviewcontroller).pageIndex;

if ((index == 0) || (index == NSNotFound)) {

return nil;

}

index++;

return [self secondviewcontrollerAtIndex:index];

}


- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)PageContentViewController

{

NSUInteger index = ((PageContentViewController2*) PageContentViewController).pageIndex;

if (index == NSNotFound) {

return nil;

}

index--;

// if (index == [self.pageTitles count]) {

// return nil;

// }

return [self secondviewcontrollerAtIndex:index];

}


- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController

{

// return [self.pageTitles count];

return 2;

}


- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController

{

return 0;

}



@end


Answers (1)
1
Tapan Patel

Tapan Patel

NA 8.1k 100.9k 8y
As Vishal suggested, please narrow down the issue to certain portion of the code.
Try using SQL Profiler to understand the network flow to database.
Is your application multi-tier?
0
David Jones

David Jones

NA 6 3 8y

Hello,

I was facing the same problem, I also tried to resolve this by myself but unable to do so. However, this company MSP IT Concepts www (dot) mspconcepts (dot) com resolved this for me. They have excellent ASP.NET development team which helped me fix this and many other bugs in my ASP.NET related stuff. you may want to get in touch with brijesh.l at mspconcepts (dot) com I'm sure they would be able to help. They are professionals & quick to provide accurate solution for your web development projects.

Thanks

0
Vishal Jadav

Vishal Jadav

NA 1.7k 57.9k 8y
Hi Mark,
Where actually you are facing this slow issue?
I mean in a particular page or overall.
check the code and minimize the lines if possible.
And if possible share a portion of code so that we can try to analyze it.
Thank you,
Cheers...