运行 应用时未找到单元标识符

Cell Identifier not found when running app

我使用 UITables 很长时间了,最​​近从 Xcode 11.7 更新到 Xcode 12.

我创建了一个新的 table 并放入了一个带有标识符“cellAutocomplete”的 Cell Prototype 中,但是当试图在“cellForRowAt”处将单元格出队时,我收到错误消息:

** 由于未捕获的异常 'NSInternalInconsistencyException' 而终止应用程序,原因:'unable to dequeue a cell with identifier cellAutocomplete - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' **

cellForRowAt 中的代码:

case tableAddressAutocomplete:
      let cell = tableView.dequeueReusableCell(withIdentifier: "cellAutocomplete", for: indexPath)
      let addressToDisplay = self.listOfAutocompletePredictions?[indexPath.row]
      cell.textLabel?.font = UIFont(name: "Graphik-Regular", size: 15.0)
      cell.textLabel?.text = addressToDisplay?.attributedFullText.string
      return cell

故事板中确实存在单元格标识符,并在 IB 的相应字段“标识符”中输入,但这是第一次发生这种情况。

我什至将标识符从 Inspector 直接复制到代码中,但我总是得到同样的错误。

在 Xcode 12 中是否发生了某些更改从而导致了错误或者可能是什么地方出了问题?我实际上在另一个 VC 上使用了相同的想法,但那是在使用 Xcode11.7 时(并且 VC 仍在工作)。

VC structure

Identifier in cell properties

似乎 IBOutlet 可能在某处引用不正确,或者您的 tableview 在您的 VC 中引用了不正确的表视图(如果您有多个表视图)

  1. 在 SearchListVC 故事板中,移除 TableAutoComplete F...
  2. 的 IBOutlet
  3. re-add出口
  4. 确保您在 viewDidLoad 或故事板中将正确的 TableAutoComplete F... 委托和数据源设置为自身
  5. 确保委托方法中的 tableview 实际上引用了 TableAutoComplete F... tableview
  6. 清理项目