
extension UIbutton { convenIEnce init(target: AnyObject) { self.init(type: .system) self.addTarget(target,action: Selector("setLang:"),for: .touchUpInsIDe) }} 在VIEwController中,当使用自定义init函数创建按钮时,作为目标,我传递自我.
这在将我的代码升级到Swift 3之前工作正常.但是,现在,当点击按钮时我收到错误:
Terminating app due to uncaught exception ‘NSinvalidargumentexception’,reason: ‘-[MyApp.VIEwController setLang:]: unrecognized selector sent to instance xxx
在VIEwController内部,声明了以下被调用的函数:
func setLang(button: UIbutton) { //...} 有任何想法吗?
提前致谢!
selectionbutton.addTarget(self,action: #selector(SingleQuestionVIEwController.selected(_:)),for: .touchUpInsIDe)总结
以上是内存溢出为你收集整理的ios – 用于不同ViewController的选择器全部内容,希望文章能够帮你解决ios – 用于不同ViewController的选择器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)