如何判断UIScrollView 的滚动方向? 代码如下:
float lastContentOffset;
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
int currentPostion = scrollView.contentOffset.y;
if (currentPostion - lastContentOffset > 15) {
lastContentOffset = currentPostion;
// NSLog(@"ScrollUp now");
}
else if (lastContentOffset - currentPostion > 15)
{
lastContentOffset = currentPostion;
// NSLog(@"ScrollDown now");
}
};
/*15表示滑动多少距离才开始判断,可以自定义.....左右方向同理*/
网友评论