My code:
[self.scrollView.panGestureRecognizer addTarget:self action:@selector(handlePanForScrollView:)];
- (void)handlePanForScrollView:(UIPanGestureRecognizer *)gesture {
switch (gesture.state) {
case UIGestureRecognizerStateBegan:
startScrollPoint = [gesture locationInView:self.scrollView];
break;
case UIGestureRecognizerStateEnded: {
NSLog(@"end");
}
default:
;
break;
}
}
Began state works fine. But my NSLog shows my end all time while scrolling (as it should be state changed). What is the right way to detect the end state of gesture recognizer?
did you consider to use and implement the "normal" methods of a UIScrollViewDelegate protocol? they should be enough for your uses, if you don't need else not mentioned in your question:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
NSLog(@"scrolling now");
}
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
NSLog(@"stop scrolling");
}
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
NSLog(@"going to scroll");
}
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