If it is not solved yet, I solved the problem for me.
I added a UIPanGestureRecognizer to the UIScrollView to detect two finger gestures, and the default behavior of the UIScrollView (scroll to something) still works.
So what I did was add the UIPanGestureReconizer to the UIScrollView:
UIPanGestureRecognizer *pangestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(displayReloadIndicator:)]; pangestureRecognizer.minimumNumberOfTouches = 2; pangestureRecognizer.delegate = self; [self.scrollView addGestureRecognizer:pangestureRecognizer]; [pangestureRecognizer release];
After that, I added the code:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return YES; }
After that I applied the action method of gesture recognition recognizers.
- (void) displayReloadIndicator:(UIPanGestureRecognizer*) panGestureRecognizer { UIGestureRecognizerState gestureRecognizerState = gestureRecognizer.state; CGPoint translation = [gestureRecognizer translationInView:self.scv_bibgesamt]; if (gestureRecognizerState == UIGestureRecognizerStateBegan) {
UPDATE:
If you want to integrate drag and drop functionality from your navigation controller, you must integrate the following code:
- (void) viewDidLoad { [super viewDidLoad]; if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = YES; self.navigationController.interactivePopGestureRecognizer.delegate = nil; }
and
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { if (gestureRecognizer == _panGestureRecognizer && [self.navigationController.viewControllers count] > 1) { CGPoint point = [touch locationInView:self.view.window]; if (point.x < 20 || point.x > self.view.window.frame.size.width - 20) { return NO; } } return YES; }
source share