触摸取消时,将 UISearchbar 作为标题隐藏在 UITableview 中 [英] Hide UISearchbar as header inside UITableview when cancel is touched

查看:22
本文介绍了触摸取消时,将 UISearchbar 作为标题隐藏在 UITableview 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 UISearchDisplayController 集成到控制器的 xib 中.我要使用的基本功能是在表格的标题中包含搜索栏,并在导航栏中显示搜索显示的按钮.

I have integrated a UISearchDisplayController into my controller's xib. The basic functionality I'm going for is to have the search bar in the header of the table, and a button in the navigation bar that shows the search display.

我遇到的问题:当取消被触摸时,我想让搜索栏不可见(保持表格使索引 0 显示在顶部,而不是搜索栏),但它保持可见而我不是确定原因(见第三张图片).任何想法如何在触摸取消按钮时始终保持搜索栏隐藏(见图 1).

What I'm stuck on: When the cancel is touched, I want to make the searchbar invisible (keep the table so index 0 is show at top, not the search bar), but it stays visible and i'm not sure why (see 3rd image). Any ideas how to always keep the searchbar hidden when the cancel button is touched (see image 1).

我尝试过的:

  1. 将 tableview contentOffset 设置为 44.这最初有效.
  2. 调用 [tableview scrollToRowAtIndexPath:....],这似乎没有任何作用.

推荐答案

如果您已将搜索栏声明为这样的属性

If you've declared your search bar as a property like that

@property(nonatomic, retain)UISearchBar *searchBar;

你可以设置

tableView.tableheader = nil;

然后重新设置

tableView.tableHeader = searchBar;

当您再次需要它时.

这篇关于触摸取消时,将 UISearchbar 作为标题隐藏在 UITableview 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆