Ste*_*fan 7 iphone cocoa-touch uikit searchdisplaycontroller
使用searchDisplayController时如何更改标签"No Results"?
问候
ohh*_*rob 14
我从没有空结果集成功地删除了标签.
如果由于从服务器获取结果而没有结果,请将数据源重置为单行,并使其显示空白表视图单元格.
此外,使用逻辑重新选择"虚拟"单元格:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *listItem = [self.filteredListContent objectAtIndex:indexPath.row];
if ([listItem isEqualToString:@""]) {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
}
Run Code Online (Sandbox Code Playgroud)
我还发现有必要在willSelect委托方法中添加"虚拟"单元格逻辑:
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *listItem = [self.filteredListContent objectAtIndex:indexPath.row];
if ([listItem isEqualToString:@""]) {
return nil;
}
return indexPath;
}
Run Code Online (Sandbox Code Playgroud)
dre*_*ewh 11
它不是直接可访问的,因此您必须以旧式方式进行操作并手动筛选您的子视图searchDisplayController.searchResultsTableView.这是一个例子:
UITableView *tableView = self.searchDisplayController.searchResultsTableView;
for( UIView *subview in tableView.subviews ) {
if( [subview class] == [UILabel class] ) {
UILabel *lbl = (UILabel*)subview; // sv changed to subview.
lbl.text = @"My custom string";
}
}
Run Code Online (Sandbox Code Playgroud)
我不推荐这个,因为你依赖于内部行为,searchResultsTableView这种行为很可能会在某些时候发生变化,打破你的应用程序.向Apple打开错误/功能请求将是一个很好的方式来到这里.
| 归档时间: |
|
| 查看次数: |
5609 次 |
| 最近记录: |