使用滑动手势更改视图控制器

时间:2017-08-28 09:57:40

标签: ios swift uiswipegesturerecognizer

我想使用滑动手势使用正确的方向移动到另一个视图控制器。你能救我吗?

@IBAction func right(_ sender: UISwipeGestureRecognizer) {

    // what I must write here

}

1 个答案:

答案 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
        }
    }


}