Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change the text "no results" when search in tableview?

After search in UITableView with no result, I want to change the text "No results" to "Not Match...".But I can't find where.Please help!

enter image description here

Here is some 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";
                }
            }
}
}
like image 274
LE SANG Avatar asked Feb 18 '23 00:02

LE SANG


1 Answers

It's an old thread, but for anyone having the same issue, 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;
    }
}
like image 109
pixelsize Avatar answered Mar 03 '23 17:03

pixelsize