Sam to rozwiązałem.
Anuluj Przycisk>
(void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller {
[controller.searchBar setShowsCancelButton:YES animated:NO];
for (UIView *subview in [controller.searchBar subviews]) {
if ([subview isKindOfClass:[UIButton class]]) {
[(UIButton *)subview setTitle:@"_____" forState:UIControlStateNormal];
}
}
}
Brak wyników Tekst>
- (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView {
if (!isChangedNoResults) {
if ([contactManager.filteredPeople count] == 0) {
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(changeNoResultsTextToKorean:) userInfo:nil repeats:YES];
}
}
}
używam wartość timera i bool. Jeśli nie ma zegara, nie można zmienić tekstu, gdy "Brak wyników" pokazuje się jako pierwszy.
- (void)changeNoResultsTextToKorean:(NSTimer *)timer {
if (isChangedNoResults) {
[timer invalidate];
}
else {
for (UIView *subview in [self.searchDisplayController.searchResultsTableView subviews]) {
if ([subview isKindOfClass:[UILabel class]]) {
UILabel *targetLabel = (UILabel *)subview;
if ([targetLabel.text isEqualToString:@"No Results"]) {
NSLog(@"Changed!");
[targetLabel setText:@"_____"];
isChangedNoResults = YES;
[timer invalidate];
}
}
}
}
}
czy mimo to można to zrobić bez przeszukiwania subviews w iOS 5.0 i Arc? – inforeqd
Może to nie jest potrzebne w iOS5 + – ChangUZ
Napisałem odpowiedni artykuł na temat tego rodzaju problemów: http://artsy.github.com/blog/2012/05/11/on-making-it-personal--in-iOS -with-searchbars/ – orta