多个手势似乎不起作用(*自定义手势识别器和UILongPressGesture识别器)



我做了一个自定义手势识别器,并将其添加到我的自定义视图中。自定义手势是 UIPanGestureRecognizer 的一个子类。

im添加的另一个手势是LongPressGestureRecognizer

                    CustomGestureRecognizer *pan;
                pan = [[CustomGestureRecognizer alloc] initWithTarget:[self viewController] action:@selector(dragImage:)];
                [pan setDirection:DirectionPangestureRecognizerVertical];
                [pan setMinimumNumberOfTouches:1];
                [pan setMaximumNumberOfTouches:1];
                [custom addSubview:custom.imageView];
                [custom addGestureRecognizer:pan];
                [pan release];
                UILongPressGestureRecognizer *highLight = [[UILongPressGestureRecognizer alloc] initWithTarget:[self viewController] 
                                                                                            action:@selector(highlightImage:)];
                [highLight setDelaysTouchesBegan:0.1];
                [tempView addGestureRecognizer:highLight];
                [highLight release];

我也实现了

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    if (![gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]] && ![otherGestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) 
    {
        return YES;
    }
    return YES;
}

我都是我的[self viewController]和self类,但我仍然没有得到同时工作的手势。

您忘记设置手势识别器的委托...永远不会调用该方法。

最新更新