如何判斷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表示滑動多少距離才開始判斷撰糠,可以自定義.....左右方向同理*/