本文转载至 http://www.cnblogs.com/pengyingh/articles/2350154.html

- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller {

UISearchBar *searchBar = self.searchDisplayController.searchBar;

[searchBar setShowsCancelButton:YES animated:YES];

for(UIView *subView in searchBar.subviews){

if([subView isKindOfClass:UIButton.class]){

[(UIButton*)subView setTitle:@"取消" forState:UIControlStateNormal];

}

}

}

No Results:

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString

{

[self filterContentForSearchText:searchString];

if ([filteredListPinYin count] == 0) {

UITableView *tableView1 = self.searchDisplayController.searchResultsTableView;

for( UIView *subview in tableView1.subviews ) {

if( [subview class] == [UILabel class] ) {

UILabel *lbl = (UILabel*)subview; // sv changed to subview.

lbl.text = @”没有结果”;

}

}

}

// Return YES to cause the search result table view to be reloaded.

return YES;

}

 
 

自定义UISearchDisplayController的“No Results“标签和”Cancel“按钮的更多相关文章

  1. Kotlin 第一弹:自定义 ViewGroup 实现流式标签控件

    古人学问无遗力, 少壮工夫老始成.纸上得来终觉浅, 绝知此事要躬行. – 陆游 <冬夜读书示子聿> 上周 Google I/O 大会的召开,宣布了 Kotlin 语言正式成为了官方开发语言 ...

  2. [flask] jinja自定义filter来过滤html标签

    问题描述 数据库存储了html格式的博客文章,在主页(index)显示的时候带有html标签,如何过滤掉呢? 解决方案 用jinja自定义filter过滤掉html标签 我是用的工厂函数,因此在工厂函 ...

  3. 更改UIsearchbar 的背景和cancel按钮(转)

    修改背景 searchbar =[[UISearchBar alloc]initWithFrame:CGRectMake(,KTopBarHeight, , KTopBarHeight)]; sear ...

  4. 自定义JSP中的Taglib标签之四自定义标签中的Function函数

    转自http://www.cnblogs.com/edwardlauxh/archive/2010/05/19/1918589.html 之前例子已经写好了,由于时间关系一直没有发布,这次带来的是关于 ...

  5. JAVAEE——struts2_04:自定义拦截器、struts2标签、登陆功能和校验登陆拦截器的实现

    一.自定义拦截器 1.架构 2.拦截器创建 //拦截器:第一种创建方式 //拦截器生命周期:随项目的启动而创建,随项目关闭而销毁 public class MyInterceptor implemen ...

  6. android 自定义流布局。实现热门标签。开源库SimpleFlowLayout

    前言 实际项目中需要实现一个 热门搜索 的栏目,类似下图: 由于 子项(子view) 中的文字是可变的,一行能显示的 子项 的个数也无法确定.需要支持自动换行和计算位置. 开源类库 我自己写了个 自定 ...

  7. 自定义ASP.NET MVC Html标签辅助方法

    原文:https://blog.csdn.net/a497785609/article/details/50184779 在ASP.NET MVC中,Html辅助方法给我们程序员带来很多方便,其重要性 ...

  8. 自定义UISearchDisplayController中搜索到结果的cell的位置

    #pragma mark - UISearchBarDelegate//当搜索文本被改变的时候调用 - (void)searchBar:(UISearchBar *)searchBar textDid ...

  9. JSP自定义不带属性和标签体的简单标签

    1. 新建HelloTag类 2. 添加额外的Jar包 (1). 右键项目 -> Build Path -> Configure Build Path -> Libraries -& ...

随机推荐

  1. python3--__getattr__和__setattr__捕捉属性的一个引用

    __getattr__和__setattr__捕捉属性的一个引用 __getattr__方法是拦截属性点号运算.更确切地说,当通过对未定义(不存在)属性名称和实例进行点号运算时,就会用属性名称为字符串 ...

  2. post 发送ajax请求

    1.ajax五步曲 <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

  3. Git 常用命令整理(持续更新)

    #配置 git config --global user.name "Your Name" git config --global user.email "email@e ...

  4. SPOJ GSS3 Can you answer these queries III ——线段树

    [题目分析] GSS1的基础上增加修改操作. 同理线段树即可,多写一个函数就好了. [代码] #include <cstdio> #include <cstring> #inc ...

  5. getParameter 与 getAttribute的区别

    request.getAttribute():是request时设置的变量的值,用request.setAttribute("name","您自己的值");来设 ...

  6. jenkins换端口号

    两个地方 1,检查 /etc/init.d/jenkins 脚本,修改 do_start 函数的 check_tcp_port 命令,端口号从 8080 换成 8082: 2,修改 /etc/defa ...

  7. 使用Jackson在Java中处理JSON

    在工作中实际使用到Java处理JSON的情况,且有很大部分都使用的是开源工具Jackson实现的. 一.入门 Jackson中有个ObjectMapper类很是实用,用于Java对象与JSON的互换. ...

  8. C#.net的常用函数列表

    原文发布时间为:2008-08-03 -- 来源于本人的百度文章 [由搬家工具导入] 1、DateTime 数字型 System.DateTime currentTime=new System.Dat ...

  9. Redis集群模式配置

    redis集群部署安装: https://blog.csdn.net/huwh_/article/details/79242625 https://www.cnblogs.com/mafly/p/re ...

  10. chromedriver错误信息提示

    The open chrome driver window displays: Starting ChromeDriver (v2.8.241075) on port 10820 [8804:7492 ...