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 outlook无法配置成功
  • ¥15 Pwm双极模式H桥驱动控制电机
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换