如何以编程方式将 IBAction 添加到按钮?
button.addTarget(self, action: Selector(("buttonAction:")), for:
.touchUpInside)
func buttonAction(sender: Any) {
print("test")
}
这给了我一个“Thread 1: signal SIGABRT”错误。
最佳答案
swift 4 版本:
button.addTarget(self, action: #selector(action(sender:)), for: .touchUpInside)
@objc private func action(sender: Button) {
print("test")
}
关于ios - 如何在 Swift 4 中以编程方式将 IBAction 添加到按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46949969/