UIScrollView 委托方法未正确调用 [英] UIScrollView delegate methods not calling properly

查看:33
本文介绍了UIScrollView 委托方法未正确调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了向上和向下滚动,我需要调用两种方法,因为我使用了下面的方法.我使用 scrollview 委托方法 作为 UICollectionUIScrollView 的子视图.这是我写的代码,但滚动不容易移动,结果有时也不准确,有人可以建议吗?

In order to scroll up and down i need to call two methods for that I have used the below method .I am using scrollview delegate method for UICollection as it is the subview for UIScrollView.Here is the code that I have written but the scroll is not easily moving and the result is also not accurate for some times can any one suggest.?

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
    CGPoint mScrollPosition = [scrollView.panGestureRecognizer velocityInView:mCollectionView];


    if (mScrollPosition.y > 0.0f){
        NSLog(@"going down");
       //Action One
        mYearHeaderTitle--;
        [self.mCollectionView reloadData];

    }
    else if (mScrollPosition.y < 0.0f){
        NSLog(@"going up");
      //Action two
        mYearHeaderTitle++;
        [self.mCollectionView reloadData];
    }
}

推荐答案

使用 :

  1. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  2. - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView

相反:

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView

这篇关于UIScrollView 委托方法未正确调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆