facebook twitter hatena line email

「Ios/swift/左右ジェスチャー」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(ページの作成:「 class WebViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let rightSwipe = UISwipeGestureRecognizer(target: self...」)
 
(相違点なし)

2016年8月5日 (金) 20:38時点における最新版

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")
       }
   }
}

参考:http://qiita.com/kentarohorie/items/71dddd6f2ea96fa00b39