UISearchDisplayController “No Results“和 cancel按...
2013-07-19 00:00
423 查看
通过 查看UISearchDispalyController的delegate方法以及它本身属性
了解到他的一些方法,而通过测试,No Results字符的更改放到
- (void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView;方法中更为好一些,我看到有朋友放到shouldreload方法中的 不过第一次还是会显示NO Results 所以效果不好,但是我测试,delegate方法shouldreload方法是发生在willShowSearchResultsTableView之前的,但是为什么更改默认的ResultsTableView的resultlable属性,shouldreload第一次不会改变,第二次执行shouldreload的时候就会显示“无结果”。
但是如果你是在willShowSearchResultsTableView方法中更改的话,第一次就会显示效果。
一下是我写的 更改方法
- (void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView
{
for (UIView *subview in tableView.subviews) {
if ([subview isKindOfClass:[UILabel class]]) {
[(UILabel *)subview setText:@"无结果"];
}
}
}
关于cancel的更改,本来是想在
viewDidLoad中加载可是,那样的话初始的searchbar就会存在那个cancel button 视觉效果不好,所以我改在
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller中添加。
以下是更改代码
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
controller.searchBar.showsCancelButton = YES;
for(UIView *subView in controller.searchBar.subviews)
{
if([subView isKindOfClass:[UIButton class]])
{
[(UIButton*)subView setTitle:@"取消" forState:UIControlStateNormal];
}
}
}
了解到他的一些方法,而通过测试,No Results字符的更改放到
- (void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView;方法中更为好一些,我看到有朋友放到shouldreload方法中的 不过第一次还是会显示NO Results 所以效果不好,但是我测试,delegate方法shouldreload方法是发生在willShowSearchResultsTableView之前的,但是为什么更改默认的ResultsTableView的resultlable属性,shouldreload第一次不会改变,第二次执行shouldreload的时候就会显示“无结果”。
但是如果你是在willShowSearchResultsTableView方法中更改的话,第一次就会显示效果。
一下是我写的 更改方法
- (void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView
{
for (UIView *subview in tableView.subviews) {
if ([subview isKindOfClass:[UILabel class]]) {
[(UILabel *)subview setText:@"无结果"];
}
}
}
关于cancel的更改,本来是想在
viewDidLoad中加载可是,那样的话初始的searchbar就会存在那个cancel button 视觉效果不好,所以我改在
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller中添加。
以下是更改代码
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
controller.searchBar.showsCancelButton = YES;
for(UIView *subView in controller.searchBar.subviews)
{
if([subView isKindOfClass:[UIButton class]])
{
[(UIButton*)subView setTitle:@"取消" forState:UIControlStateNormal];
}
}
}
相关文章推荐
- UISearchDisplayController “No Results“ cancel修改
- UISearchDisplayController “No Results“ cancel修改
- UISearchDisplayController “No Results“ cancel修改
- IOS:自定义UISearchDisplayController的cancel和no results
- UISearchDisplayController “No Results“ cancel修改
- How do I cover the “no results” text in UISearchDisplayController's searchResultTableView?
- UISearchDisplayController animate Cancel button
- UISearchDisplayController 去除“No Results”,“无结果” 的显示方法
- ios7 UISearchDisplayController cancel button title 自定义取消按键标题
- ios UISearchDisplayController 实现 UITableView 搜索功能
- iOS应用中UISearchDisplayController搜索效果的用法
- UISearchBar 和 UISearchDisplayController的使用
- UISearchBar和UISearchDisplayController
- UISerachBar / UISearchDisplayController
- UISearchDisplayController
- 点击搜索取消UISearchDisplayController的搜索状态
- UISearchBar 和 UISearchDisplayController的使用
- UISearchBar和UISearchDisplayController
- IOS-模糊搜索UISearchBar+UISearchDisplayController
- UISearchBar和 UISearchDisplayController的使用