Scroll UICollectionView to bottom

前端 未结 13 924
梦毁少年i
梦毁少年i 2021-02-02 12:05

I would like to scroll the UICollectionView to the bottom so the last item is in the view. I have tried to use scrollToItemAtIndexPath but it does not seem to be working. I want

13条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-02 12:47

    You can track top and bottom of your visible view and load next page of items

      func scrollViewDidScroll(_ scrollView: UIScrollView) {
    
        if (scrollView.contentOffset.y >= (scrollView.contentSize.height - scrollView.frame.size.height)) {
            print("bottom")
        }
    
        if (scrollView.contentOffset.y <= 0) {
            print("top")
        }
    }
    

提交回复
热议问题