How to change the text "no results" when searching in a table?

After searching in a UITableView without a result, I want to change the text "No results" to "Do not match ...". But I can’t find where. Please, help!

enter image description here

Here is the code:

- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar{ if ([self.webSearchData count] == 0) { for (UILabel *label in self.searchTable.subviews) { if (label.text = @"No Results") { label.text = @"Not Match"; } } } } 
+4
source share
4 answers

Create a custom view with a label labeled "No Results" and load it when your search query does not contain a value.

+2
source

This is an old thread, but for those who have the same problem, try something like this.

 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (tableView == _searchDisplayController.searchResultsTableView) { if (_searchResults.count == 0) { for (UIView *view in tableView.subviews) { if ([view isKindOfClass:[UILabel class]]) { ((UILabel *)view).text = @"YOUR_TEXT"; } } } return _searchResults.count; } else { return (_items.count == 0) ? 0 : _items.count; } } 
+3
source

Go through the subviews and find the UILabel in it and specify that its subheading, which we are looking for to check the line / text, corresponds to "No results" ".
if it matches, just change the text to "No match . "

or

or display a single line with an empty cell when you are still expecting the user to click the search button.

+2
source

If you change the local localization development area in your Info.plist, the string will be replaced with the native language version. If you change, for example. it will be "Keine Ergebnisse". This is tested on iOS 9. You can try to change the text through internationalization. Perhaps this is useful for some people who read and search for this stream.

associated with: searchDisplayController: change the label "No results"

0
source

All Articles