2

I am trying to implement pagination in CollectionView which contains three items in a row. For that I used:-

func scrollViewDidScroll(_ scrollView: UIScrollView) {
        if (scrollView.contentOffset.y == scrollView.contentSize.height - scrollView.frame.size.height), let urlValue = nextPageUrl {
            getMoreData(url: urlValue)
        }
    }

When I go on last item this condition executes and API is called then it refreshes collectionView by using collectionView.reloadData() . But after this reload collectionView scrolls to top Automatically and its content offset is changed. And by some way this pagination scroll condition matches again(due to scrolling on top) and API called twice. I used pagination in tableview and this issue don't come there but first time I used pagination in collectionview and getting this issue. I tried multiple solutions but no one worked, So is there any way to prevent collectionview scrolling on top to solve this issue or is it collectionview internal issue?

Piyush Naredi
  • 159
  • 1
  • 10

0 Answers0