gpt4 book ai didi

ios - SpriteKit 和 UISwipeGestureRecognizer

转载 作者:搜寻专家 更新时间:2023-10-31 22:03:59 26 4
gpt4 key购买 nike

在我的 viewDidLoad 函数中,我设置了一个滑动手势识别器:

var swipeRecognizer:UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: Selector("move"))
swipeRecognizer.direction = .Right
view.addGestureRecognizer(swipeRecognizer)

然后我设置移动函数:

func move(swipe:UISwipeGestureRecognizer) {
NSLog("swiped")
}

但是,当我向右滑动时,我不断收到以下错误:

[_TtC8swiftris9GameScene move]: unrecognized selector sent to instance 0xc81c200
2014-06-03 14:52:57.560 swiftris[45440:6777826]
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[_TtC8swiftris9GameScene move]: unrecognized selector sent to instance 0xc81c200'

可能是什么问题?

最佳答案

您将函数定义为 move(swipe:UISwipeGestureRecognizer),它映射到 obj-c 方法名称 move:,但您的选择器只是 "移动”。您需要改用 "move:"

关于ios - SpriteKit 和 UISwipeGestureRecognizer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24023811/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com