gestureRecognizerShouldBegin

gestureRecognizerShouldBegin

我有一个pan手势,我需要检查手势何时开始。在objective-C中,您可以使用

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer

而且有可能用维吾尔识别器超载
- (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer

但是很快
override func gestureRecognizerShouldBegin(gestureRecognizer: UIPanGestureRecognizer) -> Bool {

它不起作用又回来了
使用选择器“gestureRecognizerShouldBegin:具有不兼容的类型”(UIPanGestureRecognizer)->Bool'重写方法
如何快速重载此方法?

最佳答案

您不需要重载方法,而是可以执行以下操作:

override func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
    if let panGesture = gestureRecognizer as? UIPanGestureRecognizer {
        return ...
    }
    else {
        return ...
    }
}

09-06 12:35