【发布时间】:2014-11-22 20:12:20
【问题描述】:
我正在使用平移手势识别器,我需要检测初始触摸点才能采取行动。我正在使用以下代码;
@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
可能是什么问题?
【问题讨论】:
标签: ios swift uipangesturerecognizer