Pageboy icon indicating copy to clipboard operation
Pageboy copied to clipboard

When scrolling, sometimes a viewcontroller would get skipped (index not consistent)

Open gabuchan opened this issue 6 years ago • 5 comments

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 avatar Sep 03 '18 08:09 gabuchan

@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.

msaps avatar Sep 03 '18 19:09 msaps

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 avatar Sep 05 '18 14:09 gabuchan

@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 avatar Sep 06 '18 17:09 msaps

@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 avatar Sep 07 '18 04:09 gabuchan

@gabuchan okay cool, will investigate further and see what I can find. Does sound odd that it used to be fine in previous versions!

msaps avatar Sep 12 '18 07:09 msaps