0
我使用平移手勢識別器,我需要檢測初始觸摸點以採取行動。我正在使用下面的代碼;平移手勢識別器:一旦平移手勢被釋放,觸摸位置崩潰
@IBAction func panDetected(sender: UIPanGestureRecognizer) {
let touchPoint = sender.locationOfTouch(0, inView: nil)
println(touchPoint.x)
}
這些函數會在我移動手指時打印觸點。但是,一旦我從屏幕上擡起手指,它就會崩潰。這是崩潰消息;
Terminating app due to uncaught exception 'NSRangeException', reason: '-[UIPanGestureRecognizer locationOfTouch:inView:]: index (0) beyond bounds (0).'
我已經試驗過設置最小和最大觸摸限制, PAN Gesture is crashing while taking the location of touch in view in iOS
可能是什麼問題?
謝謝你的解釋!它現在有效。 – 2014-11-22 20:33:42