【发布时间】:2015-12-24 07:01:29
【问题描述】:
当我尝试向上滑动手势时,我不断收到这些错误。 “向右”滑动没问题,但“向上”滑动会引发错误。
任何帮助都会很棒。
提前致谢。
2015-12-24 14:53:36.977 滑动和摇动[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.
}
}
【问题讨论】:
标签: ios iphone swift swift2 uigesturerecognizer