UIScrollView 滚动停止的时候一次调用此方法

//拖动返回选中的索引 当滚动视图停止时的时候
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    CGFloat width = scrollView.frame.size.width;
    NSLog(@"%f",scrollView.contentOffset.x);
    int page = (scrollView.contentOffset.x + (0.5f * width)) / width;
    
    if(_delegate && [_delegate respondsToSelector:@selector(currentTabHasChanged:)] )
    {
        [_delegate currentTabHasChanged:page];
    }
}

  

原文地址:https://www.cnblogs.com/athook/p/4794764.html