UIScreenEdgePanGestureRecognizer cannot recognize gesture on right edge

I had a problem when I defined UIScreenEdgePanGestureRecognizer to detect a hard gesture appearing on the right edge of my device, but the gesture is recognized sporadically:

I have the following code:

 _swipeInLeftGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeInFromRightEdge:)];
 _swipeInLeftGestureRecognizer.minimumNumberOfTouches = 1;
 _swipeInLeftGestureRecognizer.maximumNumberOfTouches = 1;
 [_swipeInLeftGestureRecognizer setEdges:UIRectEdgeRight];
 [self.view addGestureRecognizer:_swipeInLeftGestureRecognizer];

- (void)handleSwipeInFromRightEdge:(UIGestureRecognizer*)sender
{
    NSLog(@"swipe from right edge!!!!");
}

The gesture is attached to the view without anything.

Did I miss something?

+4
source share
2 answers

I managed to create a workaround. It is pretty simple. I have subclassed UIWindow and used touchhesBegan / touchhesMoved / etc. gesture recognition simulation methods.

. UIWindow , .

:

- (CGPoint)transformPoint:(CGPoint)point {
    CGPoint pointInView = point;

    if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) {
        pointInView.x = self.bounds.size.width - pointInView.x;
        pointInView.y = self.bounds.size.height - pointInView.y;
    } else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) {
        CGFloat x = pointInView.x;
        CGFloat y = pointInView.y;
        pointInView = CGPointMake(self.bounds.size.height - y, x);
    } else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) {
        CGFloat x = pointInView.x;
        CGFloat y = pointInView.y;
        pointInView = CGPointMake(y, self.bounds.size.width - x);
    }
    return pointInView;
}
+3

, . , , , . iPad, . iPad, - , . , , .

+2

All Articles