[英]Pan gesture recognizer selector won't work
在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
我不明白這是怎么回事,我試圖在我的視圖控制器和應用程序委托中移動該函數,但似乎沒有什么區別...
更改
let panGestureRecogniser = UIPanGestureRecognizer(target: view, action: "didPan:")
至
let panGestureRecogniser = UIPanGestureRecognizer(target: self, action: "didPan:")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.