我想使用滑动手势使用正确的方向移动到另一个视图控制器。你能救我吗?
@IBAction func right(_ sender: UISwipeGestureRecognizer) {
// what I must write here
}
答案 0 :(得分:2)
只需编写一行代码 -
@IBAction func right(_ sender: UISwipeGestureRecognizer) {
if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
case UISwipeGestureRecognizerDirection.right:
self.performSegueWithIdentifier("nextView", sender: self)
break
default:
break
}
}
}