【发布时间】:2016-09-23 06:40:35
【问题描述】:
在我们开始使用 Swift 3 之后,我们遇到了这个“发送到实例的无法识别的选择器!错误,无法在合理的时间找到解决方案。我们遇到的旧版本 Swift 的所有答案。这是我们提出的行动宣言
testbutton.addTarget(self, action: Selector("testButtonAction:"), for: UIControlEvents.touchDown)
这是 Xcode 的“更正”版本,但它们都不起作用。
testbutton.addTarget(self, action: Selector(("testButtonAction:")), for: UIControlEvents.touchDown)
这是动作函数。
func testButtonAction(sender: UIButton!) {
print("Button tapped")
}
【问题讨论】: