0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

複数のボタンをまとめdidTouchUpInsideで管理

Last updated at Posted at 2021-06-30

複数のボタンdidTouchUpInsideでまとめて sender.tagにてcaseにて管理

    @IBAction func didTouchUpInside(_ sender: AnyObject) {
        //textTarget.resignFirstResponder()
        print("sender in")
        
        switch sender.tag {
        case 1:
            print("button1")
        //printerPicker!.showPicker()
        case 2:
            print("button2")
        //langPicker!.showPicker()
        case 3:
            print("button3")
        case 4:
            print("button4")
        default:
            print("sender out")
            break
        }
    }

下記の様な複数のボタンを配置し@IBAction func didTouchUpInside(_ sender: AnyObject) {....
内にcase文いて分岐する例。
スクリーンショット 2021-06-30 13.33.04.png
下記の様にドラッグし紐付けする。
スクリーンショット 2021-06-30 13.36.08.png

紐付けいしたボタンのtagIDを設定する。
スクリーンショット 2021-06-30 13.34.43.png
didTouchUpInsideがReceived Actionに追加されていることを確認。
スクリーンショット 2021-06-30 14.18.12.png

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?