New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial index #79
Comments
Do |
I'm not sure how this solution works. The viewDidLayoutSubviews gets called before the numberOfItemsAt gets called. I still get an error of an index OOB. |
Must be in main dispatch: DispatchQueue.main.async { |
But with this solution I get one frame incorrectly shown. |
I got same problems ,I put scrollToItem in DispatchQueue and viewDidLayoutSubviews but still doesn't work at all |
|
There seems no possibility to set an initial index for the current item right in setting up the pager view. So it's not possible to start the pager view at a specific position rather than always with the first item.
The FSPagerView provides a function
scrollToItem(at index: Int, animated: Bool)
to scroll to a specific item. So after setting up the pager view and registering some cells I want to scroll without animation to a specific index (before the first frame has rendered), but I get an exception, that the index is out of bounds of the number of items the collection view has. That's because thenumberOfItems
is still 0 because the layout of the collection view hasn't yet evaluated its data source methods.So the FSPagerView should either have a property like
initialIndex
orscrollToItem(at:animated:)
should handle the scrolling to the index right after the collection view layout has been prepared if called before.As a current workaround I can call
scrollToItem(at:animated:)
via GCD with zero delay in the next frame, so only one frame the wrong item will be shown.The text was updated successfully, but these errors were encountered: