Search code examples
iosuiscrollviewuipangesturerecognizer

UIScrollView UIPangestureRecognizer dead zone on top edge of screen


as shown in the picture below the UIPanGestureRecognizer will not pan when the drag started inside the "dead zone" on the top of the screen. This is most likely caused by the notification center.

enter image description here

The touchesMoved:withEvent: method however does get called, so there should be a way to get pan gestures recognized in this area.

Has anyone else came across this issue, are there any workarounds out there yet? Thanks for any help!


Solution

  • Solved the problem. The touchesMoved:withEvent: should be implemented this way:

    -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {
        UITouch *touch = [touches.allObjects objectAtIndex:0];
        CGPoint location = [touch locationInView:self];
        CGPoint previousLocation = [touch previousLocationInView:self];
        CGPoint contentOffset = self.contentOffset;
    
        contentOffset.x -= location.x - previousLocation.x;
        [self setContentOffset:contentOffset animated:NO];
    }