Lar*_*s - 2 iphone xcode uisearchbar uisearchdisplaycontroller
我有一个UISearchBar和一个UISearchBarDisplayController由xib设置.在没有结果的搜索之后,它在表格中显示"无结果".如何修改默认文字?
你也可以试试这个.
小智 5
@interface ClassName : UIViewController {
UILabel *noResultLabel;
UISearchDisplayController *searchController;
}
@implementation ClassName
- (id) init {
// bla bla bla bla
// some more bla
// setup your UISearchDisplayController and stuffz
noResultLabel = nil;
}
- (void) changeNoResultsText:(NSString *)text {
if (noResultLabel == nil) {
for (id subview in searchController.searchResultsTableView.subviews) {
if ([subview isKindOfClass:[UILabel class]]) {
if ([((UILabel *)subview).text isEqualToString:@"No Results"]) {
if (noResultLabel == nil) noResultLabel = subview;
}
}
}
}
if (noResultLabel != nil) noResultLabel.text = text;
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)bar {
[self changeNoResultsText:@"Searching..."];
}
- (BOOL) searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
[self changeNoResultsText:@"Searching full search..."];
return YES;
}
@end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4604 次 |
| 最近记录: |