【发布时间】:2016-11-06 22:59:44
【问题描述】:
首先让我说这不是关于设置重用标识符的问题。问题是我收到以下错误,尽管在情节提要中设置了重用标识符(并且尽管使用 register(cellClass:forCellReuseIdentifier:) 手动注册它)。
*** Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason:
'unable to dequeue a cell with identifier TCAccountGroups - must register a
nib or a class for the identifier or connect a prototype cell in a storyboard'
我同时使用搜索栏控制器和 NSFetchedResultsController 来创建一个可搜索的表,用户可以在现有选项或任何用户定义的选项之间进行选择。
任何建议将不胜感激。如果我遗漏了任何有用的信息,我将非常乐意提供。
编辑:我忘了提到我在 Mac OS Sierra 10.12.1 上使用 Swift 3.0.1 和 XCode 8.0.1。
编辑 2:XCode 中的倒数第二条消息是:
*** Assertion failure in -[UISearchResultsTableView
dequeueReusableCellWithIdentifier:forIndexPath:],
/BuildRoot/Library/Caches/com.apple.xbs
/Sources/UIKit_Sim/UIKit-3600.5.2/UITableView.m:6593
那么UISearchResultsTableView 类中可能存在错误?
编辑 3:这是我的连接截图:
https://i.stack.imgur.com/7Y8TA.png
https://i.stack.imgur.com/M7IU2.png
https://i.stack.imgur.com/VAaeF.png
https://i.stack.imgur.com/EJLvp.png
对于这些链接,我深表歉意,但 SO 不允许我内联保存图像。
【问题讨论】:
-
请编辑您的问题以包含您呼叫
register(cellClass:forCellReuseIdentifier:)的完整方法。 -
我在
viewDidLoad中调用它,我使用的完整方法是register(UITableViewCell.self, forCellReuseIdentifier: "TCAccountGroups")。 -
您是否为 tableViewCell 设置了标识符 TCAccountGroups?
-
我做到了,是的。我什至验证了它在故事板 XML 中,以防 Xcode 对我撒谎。 :)
-
你用过 xib 的 cell 吗?
标签: ios uitableview uisearchbar nsfetchedresultscontroller uisearchcontroller