Wednesday 9 April 2014

Objective C: Detect start of bouncing effect for UIScrollView?

static BOOL _draggingView = NO;

- (
void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
        _draggingView = YES;

}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:
(BOOL)decelerate {

      
_draggingView = NO;

}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
        NSInteger pullingDetectFrom = 50;
 
       if
(self.contentOffset.y < -pullingDetectFrom) {
           _draggingView = NO;
            NSLog(@"Pull Down");
      
        }
else if (self.contentSize.height <= self.frame.size.height && self.contentOffset.y > pullingDetectFrom) {
            _draggingView = NO;
            NSLog(@"Pull Up");
       
        }
else if (self.contentSize.height > self.frame.size.height &&
       self.contentSize.height-self.frame.size.height-self.contentOffset.y < -pullingDetectFrom) {
          _draggingView = NO;
           NSLog(@"Pull Up");
        }

}

No comments:

Post a Comment