我的部分用户遇到了崩溃
-[UITableView _configureCellForDisplay:forIndexPath:]
由于 NSInternalInconsistencyException : UITableView无法从其dataSource 获取单元格。
通过所有答案阅读stackoverflow,我可以确认:
UITableViewDatasource
和UITableViewDelegate
我用tableview注册了单元格
self.tableView.register(UINib(nibName: "MyCell", bundle: nil), forCellReuseIdentifier: "Cell")
存在cellForRowAtIndexPath方法:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
用
初始化每个单元格 cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! MyCell
在我看来,返回的单元格不能为零,因为我访问单元格并且没有发生崩溃
cell.layoutMargins = UIEdgeInsets.zero
cell.delegate = self
cell.addButton.addTarget(self, action: #selector(addButtonPressed(_:)), for: UIControlEvents.touchUpInside)
cell.selectionStyle = .none
return cell
tableview连接到领域数据库,大约有25.000个条目。有一个 notificationlistener ,一旦提交了所有插入,删除和更新,就会调用tableview.reloadData()
。在我的设备上,我无法重现崩溃。
我的用户现已确认,当他们开始在搜索字段中输入时会发生崩溃。在这种情况下,计时器启动并在0.5秒后运行更新。
然后我对结果集进行过滤和排序并存储引用。然后我将视图设置为tablefooterview并调用tableview.reloadData()