How do I cover the “no results” text in UISearchDisplayController's 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];
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, 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.
this should do the work properly. The code to return at least one cell:
and for "showing" the clean cell:
|
||
0
|
You need to realize that when you have a You can easily detect this in code, and then return the appropriate result from the delegate/data source method, depending on which tableView object is asking. For example: - (NSInteger)tableView:(UITableView *)tv numberOfRowsInSection:(NSInteger)section { if (tv == self.searchDisplayController.searchResultsTableView) { // return the number of rows in section for the visible search results. // return a non-zero value to suppress "No results" } else { // return the number of rows in section for your main data source } } The point is that your data source and delegate methods are serving two tables, and you can (and should) check for which table is asking for data or delegation.
By the way, the "No results" is (I believe) provided by a background image which the |
||
0
|
I haven't tried it myself, you can give it a try-- Link
Regards, |
||
-2
|
Try this it worked for me In the UISearchDisplayController delegate do this:=
|
版权声明:本文为博主原创文章,未经博主允许不得转载。