<分区>
Possible Duplicate:
How can I change strings of “Cancel” button, “No Results” label in UISearchBar of UISearchDisplayController?
在我的 UISearchDisplayController 中,当没有可用结果时,我想更改出现在 searchResultsTableView 中的“No Results”文本的字体。
我该怎么做?
<分区>
Possible Duplicate:
How can I change strings of “Cancel” button, “No Results” label in UISearchBar of UISearchDisplayController?
在我的 UISearchDisplayController 中,当没有可用结果时,我想更改出现在 searchResultsTableView 中的“No Results”文本的字体。
我该怎么做?
最佳答案
这里是对那里给出的答案的修改:
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller
shouldReloadTableForSearchString:(NSString *)searchString {
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.001);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
for (UIView* v in self.sbc.searchResultsTableView.subviews) {
if ([v isKindOfClass: [UILabel class]] &&
[[(UILabel*)v text] isEqualToString:@"No Results"]) {
// .. do whatever you like to the UILabel here ..
break;
}
}
});
return YES;
}
基本上,您要做的只是访问显示“无结果”文本的 UILabel。没有官方的方法可以做到这一点。如该页面上所建议的,解决方法是查找 UILabel(通过枚举搜索结果表的所有 subview )并修改它。我通常不鼓励这种事情,但我发现 Apple 拒绝提供官方方式来解决这个“无结果”标签是非常令人讨厌的,因此在这场特殊的斗争中没有任何保留。
关于iphone - UISearchDisplayController "No Results"文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8447086/
相关文章:
iphone - 在 UIScrollView 中禁用垂直滚动
ios - cocos2d 2.0-rc2 : end the director and restart
ios - Xcode 8 错误 : this class is not key value coding-compliant for the key enemyTitleLabel
iphone - UISearchDisplayController – 无法阻止在搜索栏中键入内容时重新加载表格
iphone - 开发中的 iPhone 应用程序是否比发布后运行速度更慢?
ios - 分层表格 View 和谷歌地图 View iOS Swift
ios - 使用带有 UIViewController 容器的 UISearchDisplayController