ViewPager-Swift
ViewPager-Swift copied to clipboard
Viewpager datasource method 'viewControllerAtPosition' called twice on swipe once
Hello, I noticed one thing that when I swipe from position 0 to 1 then "viewControllerAtPosition" called twice, once for position 1 and again for the position 2.
Hi @ankitpoplify ,
This library internally uses UIPageViewController. The behaviour that you are noticing is the default behaviour of UIPageViewController. It automatically loads [Previous] - [Current] - [Next] ViewControllers.
Hey, Thanks for the reply. Is there any way to call that method on every swipe with right position, because I'm using single view controller with collection view to show filtered data on every swipe. Now the problem is when I swipe from 0 to 1 position, data source methods called twice and show data of position 2 on position 1. Help me with any workaround.
Thanks & regards Ankit Singh
On Wed, 26 Jun, 2019, 19:19 nrlnishan, [email protected] wrote:
Hi @ankitpoplify https://github.com/ankitpoplify ,
This library internally uses UIPageViewController. The behaviour that you are noticing is the default behaviour of UIPageViewController. It automatically loads [Previous] - [Current] - [Next] ViewControllers.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nrlnishan/ViewPager-Swift/issues/61?email_source=notifications&email_token=AEEIBBGCOQKBCYW4QYUOADTP4NXVFA5CNFSM4H3HU562YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYTSVLA#issuecomment-505883308, or mute the thread https://github.com/notifications/unsubscribe-auth/AEEIBBCPQZDT3QFSNHVFZRTP4NXVFANCNFSM4H3HU56Q .
--
Help Save Earth. Please do not print this email unless absolutely necessary.
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by return e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. While Poplify has taken every reasonable precaution to minimize this risk of virus transmission over its network, it is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus scan before opening the e-mail or attachments. Poplify reserves the right to monitor, review and store the content of all messages sent to or from this e-mail address.
Instead of using the single instance of same view controller, how about creating 3 instances of them for position 0, 1, & 2. This would solve the problem of showing data of position 2 on position 1.
Also there is a delegate method didMoveToControllerAtIndex(index:Int)
which gets called everytime the viewcontroller for that respective position is shown. Just conform to the ViewPagerDelegate
protocol.
Can I change collection view data of returned view controller using didMoveToControllerAtIndex(index:Int)
?