在 SpriteKit 游戏中,我试图在不使用 Interface Builder 的情况下创建 UIPanGestureRecognizer,因此在我的 SKScene
的 didMoveToView
方法中,我这样写:
let panGestureRecogniser = UIPanGestureRecognizer(target: view, action: "didPan:")
view.addGestureRecognizer(panGestureRecogniser)
还是在我的 SKScene 类中,我写了这个函数:
func didPan(sender:UIGestureRecognizer) {
println("Panned")
}
我的问题是,当我运行我的应用程序时,当我在屏幕上平移时,会抛出此错误:
2015-05-12 19:28:01.955 Game[7342:2394353] -[SKView didPan:]: unrecognized selector sent to instance 0x154520690
我不明白哪里出了问题,我尝试在我的 View Controller 和应用程序委托(delegate)中移动该函数,但它似乎没有任何区别...
最佳答案
改变
let panGestureRecogniser = UIPanGestureRecognizer(target: view, action: "didPan:")
到
let panGestureRecogniser = UIPanGestureRecognizer(target: self, action: "didPan:")
关于ios - 平移手势识别器选择器不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30195386/