PagingKit icon indicating copy to clipboard operation
PagingKit copied to clipboard

0 and 1 Index [Display Data Issue]

Open faisyleo opened this issue 6 years ago • 3 comments

Overall Library is awesome ..... But there is an issue between 0 and 1 index

-> When view load and "PagContentViewController" delegate class is called then your 1 index data is overwritten by 0 index and your 1st index data display in the second index and your second index data is displayed in the third Index.

fileprivate func initialLoad(with page: Int) { numberOfPages = dataSource?.numberOfItemsForContentViewController(viewController: self) ?? 0 cachedViewControllers = Array(repeating: nil, count: numberOfPages) loadScrollView(with: page - 1) loadScrollView(with: page) loadScrollView(with: page + 1) }

And

fileprivate func loadPagesIfNeeded(page: Int? = nil) { let loadingPage = page ?? leftSidePageIndex loadScrollView(with: loadingPage - 1) loadScrollView(with: loadingPage) loadScrollView(with: loadingPage + 1) }

There is any suggestion for this issue? I solved this but this is not a permanent solution.

faisyleo avatar Nov 02 '18 06:11 faisyleo

Hi, @faisyleo.

When PageContentViewCotnroller loads view, it calls delegate to the current, prev and next index.
If the current page index is 0, the prev index is ignored. loadScrollView(with:) validates whether the argument is in the range of 0 to 'numberOfItem'.

Could you show me your code which can reproduce the issue?

kazuhiro4949 avatar Nov 04 '18 04:11 kazuhiro4949

Hi, @kazuhiro4949

Yes I know it calls delegate method to reload views and also I mention these method in my above message.

fileprivate func initialLoad(with page: Int) { numberOfPages = dataSource?.numberOfItemsForContentViewController(viewController: self) ?? 0 cachedViewControllers = Array(repeating: nil, count: numberOfPages) loadScrollView(with: page - 1) loadScrollView(with: page) loadScrollView(with: page + 1) }

And

fileprivate func loadPagesIfNeeded(page: Int? = nil) { let loadingPage = page ?? leftSidePageIndex loadScrollView(with: loadingPage - 1) loadScrollView(with: loadingPage) loadScrollView(with: loadingPage + 1) }

If you place different items in there each menu items you become to know that first two index have save data.

If you didnot founf problem then I will send you your code where I make changes.

faisyleo avatar Nov 05 '18 04:11 faisyleo

@faisyleo I'm sorry I haven't reproduce the problem yet.. If you fix some code, could you make a pull request ?

kazuhiro4949 avatar Nov 06 '18 15:11 kazuhiro4949