<分区>
在我们开始使用 Swift 3 之后,我们遇到了这个“发送到实例的无法识别的选择器!”错误,无法在合理的时间找到解决方案。我们遇到的针对旧版 Swift 的所有答案。这是我们想出的行动声明
testbutton.addTarget(self, action: Selector("testButtonAction:"), for: UIControlEvents.touchDown)
这是 Xcode 的“更正”版本,但它们都不起作用。
testbutton.addTarget(self, action: Selector(("testButtonAction:")), for: UIControlEvents.touchDown)
这是 Action 函数。
func testButtonAction(sender: UIButton!) {
print("Button tapped")
}