ios - UIPageViewController displays pages out of order and never calls viewControllerBeforeViewController -
i have uipageviewcontroller , implemented 2 optional methods on data source automatic uipagecontrol.
i have following helper methods convert between indices , view controllers.
- (uiviewcontroller *)viewcontrollerforindex:(nsinteger)index; - (nsinteger)indexfromviewcontroller:(uiviewcontroller *)viewcontroller;
the first method creates new view controller, configures specific index, , stores index in retrievable location (i.e. 1 accessed second method).
i instantiate page view controller following code:
[pageviewcontroller setviewcontrollers:@[[self viewcontrollerforindex:0]] direction:uipageviewcontrollernavigationdirectionforward animated:no completion:nil];
and here data source methods:
- (uiviewcontroller *)pageviewcontroller:(uipageviewcontroller *)pageviewcontroller viewcontrollerbeforeviewcontroller:(uiviewcontroller *)viewcontroller { nsinteger currentindex = [self indexfromviewcontroller:viewcontroller]; if (currentindex == 0) { return nil; } else { return [self viewcontrollerforindex:currentindex-1]; } } - (uiviewcontroller *)pageviewcontroller:(uipageviewcontroller *)pageviewcontroller viewcontrollerafterviewcontroller:(uiviewcontroller *)viewcontroller { nsinteger currentindex = [self indexfromviewcontroller:viewcontroller]; if (currentindex == self.data.count - 1) { return nil; } else { return [self viewcontrollerforindex:currentindex+1]; } } - (nsinteger)presentationcountforpageviewcontroller:(uipageviewcontroller *)pageviewcontroller { return self.data.count; } - (nsinteger)presentationindexforpageviewcontroller:(uipageviewcontroller *)pageviewcontroller { return 0; }
when navigate forward, works properly, when navigate backwards, view controllers start appear in random order.
i believe related fact pageviewcontroller:viewcontrollerbeforeviewcontroller: never called. page view controller calls pageviewcontroller:viewcontrollerafterviewcontroller:, when begin swiping backwards.
the uipageviewcontroller configured in storyboard follows:
- navigation: horizontal
- transition style: scroll
- spine location: none
- double sided: no
how can page view controller show view controllers in proper order?
update: when copy code brand new project, works perfectly. guess new question know of pods, frameworks, linker flags, other settings might causing behavior?
if present same page view controller on top of current page view controller recursively, bug happens on every odd version of view controller. (i.e. happens on first one, third one, etc.)
it taplytics.
i running version 1.2.34, after updating 1.2.50, fixed problem.
Comments
Post a Comment