3
votes

I ran into a quite strange behavior of UIPageViewController.

I'm using UIPageViewController to display a set of ViewControllers, so I conform to UIPageViewControllerDataSource protocol, and implemented the following method:

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(NHBufferRoomViewController *)viewController
{
    NSLog(@"Got here!!");
    NSInteger newIndex = [_imageManager currentImageIdx] + 1;
    if (newIndex >= [_imageManager count]) return nil;

    NSLog(@"%d", newIndex);
    NHBufferRoomViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"BufferRoom"];
    [controller updateImageAtIndex:newIndex];
    [[NSNotificationCenter defaultCenter] postNotificationName:kCurrentImageIndex object:[NSNumber numberWithInteger:newIndex]];
    return controller;
}

But when I swipe the page view controller, sometimes, the view controller did move to the next page, but the NSLog(@"Got here!!"); does not get called until I swipe again, this is quite strange. As far as I can understand, the page view controller should call this method when it needs to display a new page, right? But why the method is not called?

I'm setting the transition type to scroll by the way. Thanks in advance!

1
Did you already solve this problem? I'm facing the same behavior and don't have any solution...fklappan
Same here. Especially when you swipe completely from the right to the left the next page will be shown, but the method will not be called. Moving the image a bit back and forward will trigger the call. Strange...Obiwan007
@eftokay83, sadly, no. I gave up on this one..Void Main
did you solved this problem? I'm having the same issue.jayellos

1 Answers

0
votes

Yes, you are right. Its problem apple's api.

Solution : Dont go for UIPageViewController, rather implement it by UIScrollView with pagination