Pageboy
Pageboy copied to clipboard
When scrolling, sometimes a viewcontroller would get skipped (index not consistent)
So basically the view that I'm creating shows the history of actions that a user did in the past with two viewing modes: monthly and yearly. I'm using the same PageboyViewControllerDelegate
with these two modes and I'm locally tracking the "current index" for each viewing mode (when the user changes the viewing mode it would show the according month or year that he was previously seeing).
It was working perfectly under version 2.2.0
but it seemed to have broken somewhere when I tried updating to 2.5.4
(basically any version from 2.3.4
). What happens here is that at function:
func pageboyViewController(_ pageboyViewController: PageboyViewController,
willScrollToPageAt index: Int,
direction: PageboyViewController.NavigationDirection,
animated: Bool)
if the array of viewcontrollers is, let's say 9, the index
argument would start from the end (as originally set, so 8), and would jump directly to 6, then would normally continue 5-4-3-etc...
And when scrolling back, index
would skip again the number 7 for some random reason until I slowly scroll in it and kind of bruteforce the animation for the 7th viewcontroller to show. As a note I'm not changing any internal value of it and it only happen with that screen.
Am I missing something trivial here?
Thanks so much in advance!
@gabuchan sounds like a weird one! Had a quick play and I can't seem to reproduce it in the example project, would you be possibly able to supply a demo that reproduces it or video the behaviour (maybe with logs)?
For context: willScrollToPageAt
is called at the mercy of the internal UIPageViewController
, basically whenever that fires its willTransitionTo pendingViewControllers
delegate function, the Pageboy delegate is called.
Thanks for the super quick reply! Here's a small video showing what I was trying to explain earlier: pageboy example_low.zip
Apologies I omitted the logs but they basically are what the video reflects: it prints the actual index of the viewcontroller array and skips one. So when switching to Yearly
mode (the array is [2010...2018] ) it goes:
8
6
8
6
8
6
5
4
etc...
I'm printing the given index
from func pageboyViewController(_.... willScrollToPageAt.....)
Hope this helps!
@gabuchan I take it you are using Tabman with this? It somehow looks like the number of items in the TabmanBar
falls out of sync with what is in the PageboyViewControllerDataSource
. Would you maybe be able to take a look into this and see what the results are??
@msaps Negative, not using Tabman. Just plain Pageboy and custom views. Since I'm not updating any internal Pageboy variable I don't know where the problem can come from...
I'm still looking into it a bit more but it's weird that in past versions this problem isn't happening...
@gabuchan okay cool, will investigate further and see what I can find. Does sound odd that it used to be fine in previous versions!