NSInternalInconsistencyException:UITableView无法从其dataSource获取单元格

时间:2017-08-07 09:35:43

标签: ios swift uitableview

我的部分用户遇到了崩溃

-[UITableView _configureCellForDisplay:forIndexPath:]

由于 NSInternalInconsistencyException UITableView无法从其dataSource 获取单元格。

通过所有答案阅读stackoverflow,我可以确认:

  1. 我已关联UITableViewDatasourceUITableViewDelegate
  2. 我用tableview注册了单元格

    self.tableView.register(UINib(nibName: "MyCell", bundle: nil), forCellReuseIdentifier: "Cell")

  3. 存在cellForRowAtIndexPath方法:

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

  4. 初始化每个单元格

    cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! MyCell

  5. 在我看来,返回的单元格不能为零,因为我访问单元格并且没有发生崩溃

    cell.layoutMargins = UIEdgeInsets.zero
    cell.delegate = self
    cell.addButton.addTarget(self, action: #selector(addButtonPressed(_:)), for: UIControlEvents.touchUpInside)
    cell.selectionStyle = .none
    return cell
    
  6. tableview连接到领域数据库,大​​约有25.000个条目。有一个 notificationlistener ,一旦提交了所有插入,删除和更新,就会调用tableview.reloadData()。在我的设备上,我无法重现崩溃。

    我的用户现已确认,当他们开始在搜索字段中输入时会发生崩溃。在这种情况下,计时器启动并在0.5秒后运行更新。 然后我对结果集进行过滤和排序并存储引用。然后我将视图设置为tablefooterview并调用tableview.reloadData()

0 个答案:

没有答案