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];
}
}
Use :
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
Instead :
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView