UISearchDisplayController No Results Text

Possible duplicate:
How to change the lines of the Cancel, No Results button in the UISearchBar UISearchDisplayController?

In my UISearchDisplayController, I want to change the font for the text "No Results" that appears in searchResultsTableView when the results are not available.

How can i do this?

+6
ios iphone uisearchdisplaycontroller
source share
1 answer

The question may be a duplicate. How do I change the "Cancel" lines? "No results" and "No results." in UISearchBar UISearchDisplayController?

Here is a modification of the answer:

-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.001); dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ for (UIView* v in self.sbc.searchResultsTableView.subviews) { if ([v isKindOfClass: [UILabel class]] && [[(UILabel*)v text] isEqualToString:@"No Results"]) { // .. do whatever you like to the UILabel here .. break; } } }); return YES; } 

Basically, what you are asking is just to access the UILabel, which displays the text "No results." There is no official way to do this. The workaround suggested on this page is to search for UILabel (by listing all subzones of the search results table) and change. I generally can’t encourage this kind of thing, but I find Apple’s refusal to provide an official way to deal with this “No Results” label in order to be completely unpleasant, so no tricks are allowed in this particular battle.

+16
source share

All Articles