超过最大触摸次数让程序不调用touchesEnded方法?

Exceeding the maximum number of touches makes the program not to call the touchesEnded method?

我刚刚开始学习编程,运行遇到了一个问题: 我读过一些关于 iPhone 只能跟踪 5 次左右触摸的文章......但我意识到,当我用例如触摸屏幕时一次7个手指,我的程序-let停止工作了。

那么,有谁知道,当我一次触摸屏幕太多次时,代码的哪些部分会出现故障?

(我是新手。)

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
    let touch = touches.first!
    touchLocation = touch.locationInNode(self)
    nrTouches += touches.count
}
 override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
        nrTouches -= touches.count
    }

override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
    let touch = touches.first!
    touchLocation = touch.locationInNode(self)
}
override func update(currentTime: CFTimeInterval) {
    if nrTouches > 0 {
        touchingLabel.text = "touching"
    } else {
        touchingLabel.text = "not touching"
    }
}

因此,如果我同时用 7 个手指触摸,"touching" 将一直显示。 tankyuu

您缺少 touchesCancelled,它会在第 6 个手指放下时调用:

override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) { 
    if let touches = touches {
        nrTouches -= touches.count // same logic as touchesEnded
    }
}

一个有趣的提示:iPad 可以处理 11 个触摸事件。更多关于 here.