1

讓我首先說這不是關於設置重用標識符的問題。問題是,儘管在故事板中設置了重複使用標識符(儘管使用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不讓我保存圖像內聯。

+0

請編輯您的問題,包括完整的方法,你在哪裏調用'寄存器(cellClass:forCellReuseIdentifier:)'。 –

+0

我在'viewDidLoad'中調用它,我使用的完整方法是'register(UITableViewCell.self,forCellReuseIdentifier:「TCAccountGroups」)'。 – dohpaz42

+0

您是否爲您的tableViewCell設置了標識符TCAccountGroups? – nynohu

回答

1

我一直在尋找解決方案,我偶然發現可能是workable solution。如果有人知道爲什麼使用self.tableView的作品,當tableView沒有,我很想知道。

+0

取決於。您可以檢查tableView的連接檢查器,看它是否連接到UIViewController中的默認值。如果tableview在UIViewController中而不是在UITableViewController中,那麼你可能必須自己添加IBOutlet。或者,如果使用Swift 3,我認爲在許多情況下使用自己現在是一個明確的要求。 –

+0

這是一個'UITableViewController',它在表頭(使用Storyboard)中添加了一個'UISearchBarController'(搜索欄和搜索顯示控制器)。我設置的唯一出口是'UISearchBar'。 – dohpaz42

+0

當您選擇具有該問題的UI對象時,爲顯示連接的問題添加一些截圖。 –

0
  1. 打開Main.StoryBoard
  2. 選擇表的細胞,其是造成 此錯誤(你的情況TCAccountGroups)
  3. 下表視圖的「屬性檢查員」輸入標識符值即「TCAccountGroups」細胞。
  4. 構建並運行應用程序 - 此次無一例外。

Please see the image below:

相關問題