我有一个非常简单的UITableView,从iOS6开始就运行得很好….我最近尝试从iOS10-iOS11开始新的构建,现在我得到了我以前从未见过的新NSInternalConsistency异常,它实际上来了使用新的iOS版本从左侧字段开始….
*** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’,reason: ‘Attempted to dequeue
multiple cells for the same index path,which is not allowed. If you
really need to dequeue more cells than the table view is requesting,
use the -dequeueReusableCellWithIdentifier: method (without an index
path). Cell identifier: WorkOrderCell,index path: {length = 2,path = 0 – 0}’
我已经回顾了很多教程,我觉得这个代码没有什么特别的错误.事实上,正常的网格加载工作正常,这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"WorkOrderCell" forIndexPath:indexPath]; // Configure the cell... do some work,return it return cell; }
有没有其他人遇到过这个问题,你做了什么来解决它?
我应该更具体一点,正常的UITableView确实加载得很好,这个具体的问题是我有一个SearchBar,当用户输入搜索时,我正在过滤结果并显示结果网格:
//Start Search/Filter Code - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope { NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"Job contains[cd] %@ or Address contains[cd] %@ or WorkOrderId contains[cd] %@ or Supervisor contains[cd] %@",searchText,searchText]; self.filteredWorkOrders = [self.workOrders filteredArrayUsingPredicate:resultPredicate]; } -(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { [self filterContentForSearchText:searchString scope:[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]]; return YES; }
过滤器代码本身工作正常,它只是触发UITableView委托来触发,它开始出列单元格(在搜索结果网格中应该是空的?)
无论如何,我可以使用这个帮助…..