Detect page change in UICollectionView

后端 未结 7 2111
醉酒成梦
醉酒成梦 2021-01-31 03:35

I tried finding this question for a while but could not find this problem\'s answer. My problem is that i have a UICollectionView and the Scroll Direction is

7条回答
  •  温柔的废话
    2021-01-31 04:01

    Xamarin.iOS:

    You can override DecelerationEnded method of UICollectionViewDelegate or subscribe to DecelerationEnded event of UICollectionView (custom delegate will be used under the hood).

    public override void DecelerationEnded(UIScrollView scrollView)
    {
        var x = scrollView.ContentOffset.X;
        var w = scrollView.Bounds.Size.Width;
        var currentPage = Math.Ceiling(x / w);
    
        // use currentPage here
    }
    

提交回复
热议问题