2017-04-19 1 views

Répondre

0

essayer comme ça,

créer une propriété

@property (nonatomic, strong) UISearchController * searchController; 

puis ajoutez ce qui suit:

// When the user types in the search bar, this method gets called. 
- (void)updateSearchResultsForSearchController:(UISearchController *)aSearchController { 

//// .. do whatever your search results.. 

    for (UIView *subview in ((UITableViewController *)self.searchController.searchResultsController).tableView.subviews) { 
     if ([subview isKindOfClass:[UILabel class]]) { 
      if ([((UILabel *)subview).text isEqualToString:@"No Results"]) { 
       ((UILabel *)subview).textColor = [UIColor redColor]; 
      } 
     } 
     } 
} 

Modifié Ans:

for (UIView *subview in self.searchDisplayController.searchResultsTableView.subviews) { 
     if ([subview isKindOfClass:[UILabel class]]) { 
      if ([((UILabel *)subview).text isEqualToString:@"No Results"]) { 
       ((UILabel *)subview).textColor = [UIColor redColor]; 
      } 
     } 
    } 
+0

ne fonctionne pas .... – shirish

+0

comment vous avez implémenté ** UISearchController **? Est-ce comme ceci '[[UISearchController alloc] initWithSearchResultsController: searchResultsController]'? –

+0

Je l'utilise comme "self.searchDisplayController.searchResultsTableView" – shirish