Swift : 向上滑动时出错
Swift : Error when swiping up
当我尝试向上滑动手势时,我不断收到这些错误。
“向右”滑动没问题,但“向上”滑动会引发错误。
任何帮助都会很棒。
提前致谢。
2015-12-24 14:53:36.977 Swipes & Shake[58213:9895793] -[Swipes___Shake.ViewController swiped]: unrecognized selector sent to instance 0x7fc549ea4400
2015-12-24 14:53:36.982 Swipes & Shake[58213:9895793] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Swipes___Shake.ViewController swiped]: unrecognized selector sent to instance 0x7fc549ea4400'
libc++abi.dylib: terminating with uncaught exception of type 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.
}
}
您在 var swipeUp = UISwipeGestureRecognizer(target: self, action: "swiped")
的 swiped
之后错过了 :
正确的是var swipeUp = UISwipeGestureRecognizer(target: self, action: "swiped:")
当我尝试向上滑动手势时,我不断收到这些错误。 “向右”滑动没问题,但“向上”滑动会引发错误。
任何帮助都会很棒。
提前致谢。
2015-12-24 14:53:36.977 Swipes & Shake[58213:9895793] -[Swipes___Shake.ViewController swiped]: unrecognized selector sent to instance 0x7fc549ea4400
2015-12-24 14:53:36.982 Swipes & Shake[58213:9895793] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Swipes___Shake.ViewController swiped]: unrecognized selector sent to instance 0x7fc549ea4400'
libc++abi.dylib: terminating with uncaught exception of type 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.
}
}
您在 var swipeUp = UISwipeGestureRecognizer(target: self, action: "swiped")
swiped
之后错过了 :
正确的是var swipeUp = UISwipeGestureRecognizer(target: self, action: "swiped:")