当我尝试向上滑动手势时,我一直收到这些错误。 滑动"右"没事,但是" up"会抛出错误。
任何帮助都会很棒。
提前致谢。
2015-12-24 14:53:36.977 Swipes& Shake [58213:9895793] - [Swipes ___ Shake.ViewController刷过]:无法识别的选择器发送到实例0x7fc549ea4400
2015-12-24 14:53:36.982 Swipes& Shake [58213:9895793] ***由于未捕获的异常终止应用程序' NSInvalidArgumentException',原因:' - [Swipes ___ Shake.ViewController刷过]:无法识别的选择器发送到实例0x7fc549ea4400'
libc ++ abi.dylib:以NSException类型的未捕获异常终止 (lldb)
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
var swipeRight = UISwipeGestureRecognizer(target: self, action: "swiped:")
swipeRight.direction = UISwipeGestureRecognizerDirection.Right
self.view.addGestureRecognizer(swipeRight)
var swipeUp = UISwipeGestureRecognizer(target: self, action: "swiped")
swipeUp.direction = UISwipeGestureRecognizerDirection.Up
self.view.addGestureRecognizer(swipeUp)
}
func swiped(gesture: UIGestureRecognizer)
{
if let swipeGesture = gesture as? UISwipeGestureRecognizer
{
switch swipeGesture.direction
{
case UISwipeGestureRecognizerDirection.Right:
print("RIGHT")
case UISwipeGestureRecognizerDirection.Up:
print("UP")
default:
break
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
答案 0 :(得分:1)
在:
swiped
之后,您错过了var swipeUp = UISwipeGestureRecognizer(target: self, action: "swiped")
正确是var swipeUp = UISwipeGestureRecognizer(target: self, action: "swiped:")