I have a UICollectionView with 6 pages, and swapping is enabled and UIPageControl. I want that when I come to the last page, if I drag to the right, the UICollectionView reloads from the first page without any problems.
- (void)scrollViewDidEndDecelerating:(UIScrollView *)sender { // The key is repositioning without animation if (collectionView.contentOffset.x == 0) { // user is scrolling to the left from image 1 to image 10. // reposition offset to show image 10 that is on the right in the scroll view [collectionView scrollRectToVisible:CGRectMake(collectionView.frame.size.width*(pageControl.currentPage-1),0,collectionView.frame.size.width,collectionView.frame.size.height) animated:NO]; } else if (collectionView.contentOffset.x == 1600) { // user is scrolling to the right from image 10 to image 1. // reposition offset to show image 1 that is on the left in the scroll view [collectionView scrollRectToVisible:CGRectMake(0,0,collectionView.frame.size.width,collectionView.frame.size.height) animated:NO]; } pageControlUsed = NO; }
This does not work as I want. What can I do?
source share