iOS6 UICollectionView and UIPageControl - How to get visible cell?

后端 未结 7 2109
甜味超标
甜味超标 2020-12-02 12:37

While studying iOS6 new features I got a question about UICollectionView.
I am currently testing it with Flow layout and the scroll direction set to horizontal, scrolli

7条回答
  •  长情又很酷
    2020-12-02 13:00

    Another option with less code is to use visible item index path and set the page control.

    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
        self.pageControl.currentPage = [[[self.collectionView indexPathsForVisibleItems] firstObject] row];
    }
    

提交回复
热议问题