1 . 第一种
CGPoint point = [scrollView.panGestureRecognizer translationInView:self.view];
if (point.y > 0 ) {
NSLog(@"------往上滚动");
}
else {
NSLog(@"------往下滚动");
}
2 .
CGFloat scrollOffsetY = 0;
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
scrollOffsetY = scrollView.contentOffset.y;
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
scrollOffsetY = scrollView.contentOffset.y;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView.contentOffset.y > scrollOffsetY) {
NSLog(@"------往上滚动");
}
else if (scrollView.contentOffset.y < scrollOffsetY) {
NSLog(@"------往下滚动");
}
}
网友评论