swift-错误unrecognized selector sent to instance

错误提示

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DBFM.ViewController onPlay]: unrecognized selector sent to instance 0x7fe3586a3820'


相关代码

btnPlay.addTarget(self, action: "onPlay", forControlEvents: UIControlEvents.TouchUpInside)



解决方法

(带参数的方法应该加上冒号: )

btnPlay.addTarget(self, action: "onPlay:", forControlEvents: UIControlEvents.TouchUpInside)




你可能感兴趣的:(swift)