2
在我們開始使用Swift 3之後,我們一直面臨着這個'無法識別的選擇器發送到實例!錯誤並且無法在合理的時間找到解決方案。所有我們遇到的舊版Swift的答案。這是我們想出的行動聲明Swift 3和無法識別的選擇器發送到實例錯誤的按鈕創建
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")
}