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];
}
}
}
ne fonctionne pas .... – shirish
comment vous avez implémenté ** UISearchController **? Est-ce comme ceci '[[UISearchController alloc] initWithSearchResultsController: searchResultsController]'? –
Je l'utilise comme "self.searchDisplayController.searchResultsTableView" – shirish