【发布时间】:2016-01-04 10:21:58
【问题描述】:
我正在尝试使用 swift2.1 获取触摸位置并收到错误“'UITouch' 类型的值没有成员 'locationInNode'”。
这是我的代码
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
if let touch = touches.first {
let location = touch.locationInNode(self)
print(location)
}
}
我查看了源代码,发现在 UITouch 类中只有 public
func locationInView(view: UIView?) -> CGPoint {
}
这是我应该使用的东西还是...?
【问题讨论】:
-
在“使用 SpriteKit 中的触摸事件”部分下有
locatonInNode()(developer.apple.com/library/ios/documentation/UIKit/Reference/…)。也许你需要import SpriteKit? -
谢谢 NicolasMiari,明白了
标签: ios swift2 uitouch touchesbegan