Ios/swift/左右ジェスチャー
提供: 初心者エンジニアの簡易メモ
class WebViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let rightSwipe = UISwipeGestureRecognizer(target: self, action: #selector(self.didSwipe(_:))) rightSwipe.direction = .Right view.addGestureRecognizer(rightSwipe) let leftSwipe = UISwipeGestureRecognizer(target: self, action: #selector(self.didSwipe(_:))) leftSwipe.direction = .Left view.addGestureRecognizer(leftSwipe) } final func didSwipe(sender: UISwipeGestureRecognizer) { if sender.direction == .Right { print("Right") } else if sender.direction == .Left { print("Left") } } }