swift-错误unrecognized selector sent to instance

前端之家收集整理的这篇文章主要介绍了swift-错误unrecognized selector sent to instance前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

错误提示

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

@H_404_14@
相关代码
@H_404_14@

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

@H_404_14@

@H_404_14@

解决方法

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

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

@H_404_14@

@H_404_14@

猜你在找的Swift相关文章