I have a UISearchBar and a UISearchBarDisplayController set up by a xib.
After a search with no result it says "No result" some lines down in the table.
How to modify default text?
You can also try this.
@interface ClassName : UIViewController {
UILabel *noResultLabel;
UISearchDisplayController *searchController;
}
@implementation ClassName
- (id) init {
// bla bla bla bla
// some more bla
// setup your UISearchDisplayController and stuffz
noResultLabel = nil;
}
- (void) changeNoResultsText:(NSString *)text {
if (noResultLabel == nil) {
for (id subview in searchController.searchResultsTableView.subviews) {
if ([subview isKindOfClass:[UILabel class]]) {
if ([((UILabel *)subview).text isEqualToString:@"No Results"]) {
if (noResultLabel == nil) noResultLabel = subview;
}
}
}
}
if (noResultLabel != nil) noResultLabel.text = text;
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)bar {
[self changeNoResultsText:@"Searching..."];
}
- (BOOL) searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
[self changeNoResultsText:@"Searching full search..."];
return YES;
}
@end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With