Aaron挖了个坑 2017-10-11 08:43 采纳率: 0%
浏览 1146
已采纳

oc开发ios项目:用代码写控件,添加tableview时出现警告,把控件添加到view时报错

@interface ViewController (){
UITextField txtPhoneNo;
UITableView *tvCompanyCode;
}
@end
原来的一些控件在ViewController ()里面声明,执行到
[tvCompanyCode setDelegate:self];
[tvCompanyCode setDataSource:self];
[self.view addSubview:tvCompanyCode];这一句之后就报错,并且前两句有警告,警告内容如下:
Sending 'ViewController *const __strong' to parameter of incompatible type 'id _Nullable'
报错内容:
2017-10-11 16:22:25.714075+0800 Demo[1539:681757] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-10-11 16:22:25.717037+0800 Demo[1539:681757] [MC] Reading from public effective user settings.
2017-10-11 16:23:08.599117+0800 Demo[1539:681757] -[ViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x109e0b7b0
2017-10-11 16:23:08.600113+0800 Demo[1539:681757] *
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x109e0b7b0'
*** First throw call stack:
(0x18a292fd8 0x188cf4538 0x18a299ef4 0x18a296f4c 0x18a192d2c 0x19070c414 0x19049ed74 0x19049e544 0x19049e2cc 0x19049e100 0x190700480 0x1904a39bc 0x1903be750 0x1903e2104 0x1903bd9d0 0x18accca6c 0x1903bd848 0x1903c9744 0x1903c9060 0x1000a4cc8 0x1903f70ec 0x1903f706c 0x1903e15e0 0x1903f6950 0x1903f646c 0x1903f1804 0x1903c2418 0x190bbbf64 0x190bb66c0 0x190bb6aec 0x18a241424 0x18a240d94 0x18a23e9a0 0x18a16ed94 0x18bbd8074 0x190427130 0x1000a555c 0x18917d59c)
libc++abi.dylib: terminating with uncaught exception of type NSException

看网上一些tableview控件声明的地方是@interface ViewController :UIViewController
我把上面的改成这个之后其他的控件又都不能用了,请问这个应该怎么去改,刚开始学iOS开发,请大神指教,谢谢。

  • 写回答

3条回答 默认 最新

  • glustful 2017-10-11 09:26
    关注

    UITextField txtPhoneNo;这个为啥没有*号呢, reason: '-[ViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x109e0b7b0'这句话你查下这方法做了啥,你下次截图上来才能看得了错误

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献