UIPanGestureRecognizer 无法在 iPad 上运行?

UIPanGestureRecognizer not working on iPad?

我有一个 UIPanGestureRecognizer 代码如下:

self.panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panThis:)];
self.panRecognizer.delegate = self;
[self.view addGestureRecognizer:self.panRecognizer];


- (void)panThis:(UIPanGestureRecognizer *)recognizer
{
    switch (recognizer.state)
    {
        case UIGestureRecognizerStateBegan:
        {
            CGPoint panStartPoint = [recognizer translationInView:self.view];
            NSLog(@"Pan Began at %@", NSStringFromCGPoint(panStartPoint));
            break;
        }
        default:
            break;
    }
}

在 iPhone 上可以找到,但在 iPad 上,它无法识别平移手势并继续记录

Pan Began at {0, 0}
Pan Began at {0, 0}
Pan Began at {0, 0}

我的代码有什么问题吗?非常感谢

这是我的代码..有效。试一试。

- (void)handlePan:(UIPanGestureRecognizer *)recognizer {

    NSLog(@"handlePan");
    //CGPoint p;
    switch (recognizer.state) {
        case UIGestureRecognizerStateBegan:
NSLog(@"UIGestureRecognizerStateBegan");


            break;

        case UIGestureRecognizerStateEnded:
            // All fingers are lifted.
            break;

        default:
            break;
    }

    UIView * inView = recognizer.view;
    CGPoint translation = [recognizer translationInView:self.view];

    recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,
                                         recognizer.view.center.y + translation.y);

    [recognizer setTranslation:CGPointMake(0, 0) inView:self.view];

    ///relative to view.
    CGPoint center = inView.center;
    NSLog(@"handlePan %f %f", center.x, center.y);

}