Note:My question is the direction of the scrollView will scroll,not scrolling.That is to say,when user scroll the scrollView,can we get the direction of the scrollView is going to scroll before the scrollView begin scrolling?
Any idea?Thanks in advance.
By using scroll view delegate you can identify.
Objective C :
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
CGPoint point = [scrollView.panGestureRecognizer translationInView:scrollView.superview];
if (point.y > 0) {
// Dragging down
} else {
// Dragging up
}
}
Swift :
func scrollViewWillBeginDecelerating(_ scrollView: UIScrollView) {
let actualPosition = scrollView.panGestureRecognizer.translation(in: scrollView.superview)
if (actualPosition.y > 0){
// Dragging down
}else{
// Dragging up
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With