我使用 Xcode 4.2 创建了一个基于故事板的 iOS 应用程序。其中一个屏幕包含一个使用动态自定义单元格的 UITableViewController。
到目前为止 - 一切正常。
现在,我想添加一个 UISearchDisplayController 来允许对我的列表进行过滤。
由于某种原因,UISearchDisplayController 不会显示我的自定义单元格,我找不到强制它显示的方法...
这是我的 cellForRowAtIndexPath 方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"QueueListCell";
QueueListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[QueueListTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier];
}
assert(cell);
if ([tableView isEqual:self.searchDisplayController.searchResultsTableView]) {
indexPath = [_indexPathsForSearchResults objectAtIndex:indexPath.row];
}
// Set up the cell...
NSDictionary* itemDict = [_ListItems objectAtIndex:indexPath.row];
cell.labelQueueName.text = [itemDict objectForKey:kQueueName];
cell.labelQueueNumItems.text = [[itemDict objectForKey:kQueueNumItems] stringValue];
return cell;
}
有没有想法如何使这个工作?我的UISearchDisplayController表确实显示了正确数量的结果(因为我可以点击它们,并且我添加了一个NSLog来让我知道我正在点击什么...)这是我的表视图
![这是我的表格视图](https://istack.dev59.com/4Tect.webp)
![这是搜索显示表格的样子...](https://istack.dev59.com/l1BJg.webp)
感谢任何帮助...
Reuven