标签:blog class code java ext color
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
searchDisplayController.searchBar.backgroundColor = [UIColor whiteColor];
searchDisplayController.searchBar.showsCancelButton = YES;
//定义取消按钮
/*
*ios7与ios6方法不同
*/
if (IOS7_OR_LATER) {
for (id searchbutton in mySearchBar.subviews)
{
UIView *view = (UIView *)searchbutton;
UIButton *cancelButton = (UIButton *)[view.subviews objectAtIndex:2];
cancelButton.enabled = YES;
[cancelButton setTitle:@"取消" forState:UIControlStateNormal];//文字
break;
}
}else
{
for(id cancelButton in [searchDisplayController.searchBar subviews])
{
if([cancelButton isKindOfClass:[UIButton class]])
{
UIButton *btn = (UIButton *)cancelButton;
[btn setTitle:@"取消" forState:UIControlStateNormal];
}
}
}
}
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
//去除 No Results 标签
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.001);
dispatch_after(popTime, dispatch_get_main_queue(), ^{
for (UIView *subview insearchDisplayController.searchResultsTableView.subviews) {
if ([subview isKindOfClass:[UILabel class]] && [[(UILabel *)subview text] isEqualToString:@"No Results"]) {
UILabel *label = (UILabel *)subview;
label.text = @"无结果";
break;
}
}
});
return YES;
}
在UISearchDisplayController里定义取消按钮和去掉No Result,布布扣,bubuko.com
在UISearchDisplayController里定义取消按钮和去掉No Result
标签:blog class code java ext color
原文地址:http://www.cnblogs.com/farer-zcz/p/3712304.html