swift3.0 iOS10.2 で作成しています。
左右スワイプで画面を左右にスワイプしたいのですが、下から上に上がるスワイプになってしまいます。左右のスワイプにするには、どこを修正する必要がありますでしょうか?お知恵を頂戴致したく宜しくお願い申し上げます。
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() { super.viewDidLoad() //左スワイプ検知 let leftSwipe = UISwipeGestureRecognizer(target: self, action: #selector(ViewController.swipeGesture(_:))) leftSwipe.direction = .left self.view.addGestureRecognizer(leftSwipe) //右スワイプ検知 let rightSwipe = UISwipeGestureRecognizer(target: self, action: #selector(ViewController.swipeGesture(_:))) rightSwipe.direction = .right self.view.addGestureRecognizer(rightSwipe) } //スワイプ検知時の動作 func swipeGesture(_ sender: UISwipeGestureRecognizer){ //左スワイプの動作 if sender.direction == .left { //遷移先画面の紐付け(※"NextView"はStoryboardにて設定した画面IDを記述) let Swipe = self.storyboard!.instantiateViewController(withIdentifier: "NextView") as UIViewController //画面遷移処理 self.present( Swipe, animated: true, completion: nil) } if sender.direction == .right{ //遷移先画面の紐付け(※"PreviousView"はStoryboardにて設定した画面IDを記述) let Swipe = self.storyboard!.instantiateViewController(withIdentifier: "PreviousView") as UIViewController //画面遷移処理 self.present( Swipe, animated: true, completion: nil) } } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. }
}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/01/23 07:46