LoginSignup
0
0

More than 1 year has passed since last update.

画面を長押し時に検知 (UILongPressGestureRecognizer() )

Posted at

今回の内容

  • 画面を長押しを検知します。
  • 検知した時に、作成した処理を働かせる。

コードと簡単解説

  • UILongPressGestureRecognizer(target: self, action: #selector(メソッド名))で長押し時の処理を作成します。

  • viewなど.addGestureRecognizer(インスタンス)で長押し時に処理が働くようになります。

   override func viewDidLoad() {
        super.viewDidLoad()

   let longtapDetection = UILongPressGestureRecognizer(target: self, action: #selector(screenLongTap))
        view.addGestureRecognizer(longtapDetection)

   }

    @objc func screenLongTap(){

            //長押しを検知した時の処理
    }

終わり

ご指摘、ご質問などありましたら、コメントまでお願い致します。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0