Ios/swift/左右ジェスチャー
提供: 初心者エンジニアの簡易メモ
2016年8月5日 (金) 20:38時点におけるAdmin (トーク | 投稿記録)による版 (ページの作成:「 class WebViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let rightSwipe = UISwipeGestureRecognizer(target: self...」)
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") } } }