I have implemented automatic scrolling of UIPageViewController
after every 5 seconds using timer like this:
_bannerTimer = [NSTimer scheduledTimerWithTimeInterval:5.0
target:self
selector:@selector(loadNextController)
userInfo:nil
repeats:YES];
- (void)loadNextController
{
self.index++;
HeaderAdVC *nextViewController;
if(self.index>arrayImages.count-1)
{
self.index=0;
[pageIndicator setCurrentPage:0];
nextViewController = [self viewControllerAtIndex:0];
}
else
{
nextViewController = [self viewControllerAtIndex:self.index];
}
[pageIndicator setCurrentPage:self.index];
[pageController setViewControllers:@[nextViewController]
direction:UIPageViewControllerNavigationDirectionForward
animated:YES
completion:nil];
}
and removing the timer in viewWillDisappear
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[_bannerTimer invalidate];
}
Problem :
My problem is when the loadNextController
method is called my app stop responding.
If i switch to next page still getting the same problem on every view.