swift 初学者です。
コードでボタンを表示させて、実行するメソッドを記載しているのですが、ふたつ目のUIbuttonのメソッドの場所でエラーが発生してしまいます。
button2.addTarget(self, action: #selector(move(_:)), for: UIControl.Event.touchUpInside)の部分にて
エラー Use of unresolved identifier 'move'が発生します
多少コードを省いて記載してます。それとメソッド内が同一内容なのも一時的に記載しているだけですので気にせずでお願いします。
コード class ViewController: UIViewController { let button = UIButton(type: UIButton.ButtonType.system) let button2 = UIButton(type: UIButton.ButtonType.system) override func viewDidLoad() { super.viewDidLoad() button.addTarget(self, action: #selector(buttonEven(_:)), for: UIControl.Event.touchUpInside) button2.addTarget(self, action: #selector(move(_:)), for: UIControl.Event.touchUpInside) } @objc func buttonEven (_ sender: UIButton) { count += 1 if count >= 5 { button.isHidden = true } func move (_ sender:UIButton){ count += 1 if count >= 5 { button.isHidden = true } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/24 12:15
2019/08/24 12:20
2019/08/24 12:29
2019/08/24 12:47
2019/08/24 12:48
2019/08/25 02:28
2019/08/25 10:53
2019/08/26 13:11