swift按钮通过代码添加点击事件时出现unrecognized selector sent to instance 0x136ea5010错误
来源:互联网 发布:网络执法官绿色破解版 编辑:程序博客网 时间:2024/06/08 04:50
btn.addTarget(self, action:"tapped", forControlEvents:UIControlEvents.TouchDown)
2015-11-29 22:02:38.551 TextView[1753:527042] -[TextView.ViewController tapped]: unrecognized selector sent to instance 0x136ea5010
2015-11-29 22:02:38.557 TextView[1753:527042] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TextView.ViewController tapped]: unrecognized selector sent to instance 0x136ea5010'
*** First throw call stack:
(0x184aa0f48 0x199563f80 0x184aa7c5c 0x184aa4c00 0x1849a8cac 0x18a06bcfc 0x18a06bc78 0x18a053930 0x18a0743cc 0x18a06b014 0x18a063cdc 0x18a0344a4 0x18a03276c 0x184a58544 0x184a57fd8 0x184a55cd8 0x184984ca0 0x18fbc0088 0x18a09cffc 0x1000f2110 0x199db28b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
出现这个原因是由于在tapped函数里边加了一个按钮对象,如下方法所示:func tapped(button: UIButton)
{
let alert=UIAlertController()
alert.title="sxj"
alert.message="哈哈"
self.presentViewController(alert, animated:true, completion: nil)
print("哈哈")
}
第一种方法是在tapped前要加上冒号,如下代码所示:func tapped()
{
let alert=UIAlertController()
alert.title="sxj"
alert.message="哈哈"
self.presentViewController(alert, animated:true, completion: nil)
print("哈哈")
}
- swift按钮通过代码添加点击事件时出现unrecognized selector sent to instance 0x136ea5010错误
- swift-错误unrecognized selector sent to instance
- 关于reactivecocoa出现 unrecognized selector sent to instance错误
- 关于reactivecocoa出现 unrecognized selector sent to instance错误
- swift: unrecognized selector sent to instance
- "unrecognized selector sent to instance *****"的错误
- 错误:[__NSCFString md5Hash]: unrecognized selector sent to instance 0x223120'
- [UIView numberofRowsInSection]unrecognized selector sent to instance 0x1808bef0 错误
- iOS 【错误:unrecognized selector sent to instance 0x7aa552b0】
- unrecognized selector sent to instance 0x81de740
- unrecognized selector sent to instance 0x266070
- unrecognized selector sent to instance 0x266070
- unrecognized selector sent to instance 0x10b34e810
- unrecognized selector sent to instance 0x266070
- unrecognized selector sent to instance
- unrecognized selector sent to instance
- unrecognized selector sent to instance
- unrecognized selector sent to instance
- UIWindow
- ViewGroup和View的事件分发机制
- 1029. Median (25)
- Git之如何解决Error:pathspec '/layout/radar_chart.xml' did not match any file(s) known to
- Nginx和lvs在负载均衡方面的对比
- swift按钮通过代码添加点击事件时出现unrecognized selector sent to instance 0x136ea5010错误
- C语言开发总结(十七)
- Spring 配置文件中Bean 属性id和name的区别
- 10款最好用的MySQL数据库客户端图形界面管理工具
- Page Object Model (Selenium, Python)
- angular 小试
- iOS———实现抖动效果
- Excel中concatenate函数的使用方法
- 杂碎(2)