使 UISearchDisplayController 显示与其搜索的原始 tableView 完全相同的单元格(格式、高度、字体、颜色等)的最简单方法是什么?或者简单地说 - 让它出列相同的单元格标识符?
我正在使用标准的子类 UITableViewController + UISearchDisplayController 解决方案,并且更喜欢坚持使用它。
谢谢
使 UISearchDisplayController 显示与其搜索的原始 tableView 完全相同的单元格(格式、高度、字体、颜色等)的最简单方法是什么?或者简单地说 - 让它出列相同的单元格标识符?
我正在使用标准的子类 UITableViewController + UISearchDisplayController 解决方案,并且更喜欢坚持使用它。
谢谢
我实际上找到了最简单的方法。
我所要做的就是更改默认的 cellForRowAtIndexPath 第二行代码并添加“self”。到 tableView 到出队单元格标识符 - 这样,故事板中的单元格样式总是出队,而不是 searchResultsController.tableView 中的(不存在的)单元格样式
还实现 heightForRowAtIndexPath ,它将返回相同的高度而无需任何检查(searchresults 表或 self.table - 我们想要相同的高度)
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 62.0f;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"PhraseCell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// ^^^^ NEW
//...