我的程序崩溃并显示以下报告。
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7fb4e1c099b0'
这是我对 tableview 方法的实现。
崩溃日志here .
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0) {
return 6;
}
return 5;
}
任何人都可以知道为什么会发生这种情况吗?
最佳答案
错误消息表明您正在将方法 tableView:numberOfRowsInSection:
发送到 UIView 对象,该对象不理解该方法。您的 tableview 的数据源不正确,或者您打算向 UIView 发送不同的方法。
如果您找不到包含错误的代码行,您可以共享更多代码。否则,您发布的代码只是样板文件,没有任何帮助。但这就是您的错误消息的含义。
关于ios - UITableView 崩溃无法识别的选择器发送到实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40042501/