0
スウィフト#selector
が正しく理解されていないように感じます。私は別のクラスのメソッドにボタンを接続しようとしています。Swift 3クラスのメソッドがセレクタの構文で動作しない
押されたときに、私はボタンを印刷するクラスを持っている:
class printThings {
@IBAction func printMe(_ sender: UIButton){
print("Button Pushed.")
}
}
そしてのViewController:
class ViewController : UIViewController {
override func ViewDidLoad(){
super.viewDidLoad()
//button setup here
let printMe = printThings()
button.addTarget(printMe, action: #selector(printMe.printMe(_:)), for: .touchUpInside)
//add button to subview
}
}
これは、クラスのprint文をトリガーすることはありません。私は何かシンプルなものが欠けていると確信しています
ありがとうございました。