Mof*_*waw 3 xcode uibutton ios swift
如何以编程方式将IBAction添加到按钮?
button.addTarget(self, action: Selector(("buttonAction:")), for:
.touchUpInside)
func buttonAction(sender: Any) {
print("test")
}
Run Code Online (Sandbox Code Playgroud)
这给了我一个" 线程1:信号SIGABRT "错误.
Swift 4版本:
button.addTarget(self, action: #selector(action(sender:)), for: .touchUpInside)
@objc fileprivate func action(sender: Button) {
print("test")
}
Run Code Online (Sandbox Code Playgroud)