UIPinchGestureRecognizer没有超过可能状态

时间:2015-09-09 10:57:41

标签: swift uigesturerecognizer uipinchgesturerecognizer

我有

required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        self.multipleTouchEnabled = true
        let pinchRecognizer = UIPinchGestureRecognizer(target: self, action: "handlePinch:")

        pinchRecognizer.delegate = self
        self.addGestureRecognizer(pinchRecognizer)
    }

 @objc func handlePinch(recognizer:UIPinchGestureRecognizer){
        print("pinch")
        switch recognizer.state {
        case UIGestureRecognizerState.Changed:
            //Code
            break
        default:
            break
        }

但是handlePinch()永远不会被调用,所以我添加了

override func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
    print(gestureRecognizer)
    return true
}

打印

<UIPinchGestureRecognizer: 0x135d0f4e0; state = Possible; view = <Equalizer.GraphContainer 0x135e0a470>; target= <(action=handlePinch:, target=<Equalizer.GraphContainer 0x135e0a470>)>>

显然UIPinchGestureRecognizer永远不会超过“可能”状态。 一旦进入蓝色月亮,它实际上就会通过,我的handlePinch()会被调用。

我在这里缺少什么?

0 个答案:

没有答案