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'


相关代码

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



解决方法

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

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



原文链接:https://www.f2er.com/swift/326328.html

猜你在找的Swift相关文章