如何覆盖“无结果”文本在UISearchDisplayController的searchResultTableView? [英] How do I cover the "no results" text in UISearchDisplayController's searchResultTableView?

查看:157
本文介绍了如何覆盖“无结果”文本在UISearchDisplayController的searchResultTableView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想在服务器处理搜索查询时显示无结果文本。

I don't want to show the "no results" text while my server is processing a search query.

我想出了包含标签的表格单元格的精确坐标,尝试覆盖它。

I figured out the exact coordinates of the table cell that contains the label and attempted to cover it.

self.noResultsCoverView = [[[UIView alloc] initWithFrame:CGRectMake(
    0.0, 
    44.0, 
    320.0, 
    43.0
)] autorelease];
self.noResultsCoverView.backgroundColor = [UIColor whiteColor];
[self.searchDisplayController.searchResultsTableView addSubview:self.noResultsCoverView];

对于我的懊恼,我的封面在表视图上方,但低于标签。我需要盖子在标签之上。 searchResultsTableView :: bringSubviewToFront 没有工作,这让我相信标签不是 searchResultsTableView

To my chagrin, my cover was above the table view, but below the label. I need the cover to be above the label. searchResultsTableView::bringSubviewToFront didn't work, which makes me believe that the label isn't a child of the searchResultsTableView at all.

BTW,此 Stack Overflow answer doesn'对我来说相当的工作。它工作在第一次搜索,但在随后的搜索闪烁一个奇怪的黑色封面。

BTW, this Stack Overflow answer doesn't quite work for me. It works on the very first search, but flashes a weird black cover on subsequent searches.

推荐答案

解决这个问题最简单的方法是在查询正在进行时返回numberOfRowsInSection中的1,或将其隐藏属性设置为YES,因此不可见。

The easiest way to work around this is to return 1 in numberOfRowsInSection while the query is in progress and leave the dummy cell empty or set its hidden property to YES so it is not visible.

这篇关于如何覆盖“无结果”文本在UISearchDisplayController的searchResultTableView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆