【发布时间】:2011-10-10 03:03:51
【问题描述】:
最初如何隐藏 UITableView 的 UISearchDisplayController ?我只想让用户向上滚动以查看 UISearchBar。
更新:我正在考虑将 UITableView 向下滚动 40px,以便 UISearchBar 可以对用户“隐藏”。
【问题讨论】:
标签: ios uitableview ios4 uisearchdisplaycontroller
最初如何隐藏 UITableView 的 UISearchDisplayController ?我只想让用户向上滚动以查看 UISearchBar。
更新:我正在考虑将 UITableView 向下滚动 40px,以便 UISearchBar 可以对用户“隐藏”。
【问题讨论】:
标签: ios uitableview ios4 uisearchdisplaycontroller
我的解决方案在viewWillAppear:animted:
[my_table_view setContentOffset:CGPointMake(0, searchController.searchBar.bounds.size.height)];
UPDATE我们应该获取UISearchBar的高度而不是使用固定值。
【讨论】:
searchController.searchBar.bounds.height。高度可能会在未来的 iOS 版本中发生变化,这会破坏您的代码,但不会破坏这个。
searchController.searchBar.bounds.height 属性不存在。应该是searchController.searchBar.bounds.size.height
这是我在视图中隐藏搜索栏的方式。此剪辑将确保搜索栏最初仅在第一次出现调用时才隐藏。
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//hide search bar
if (_searchBarRevealed == NO) {
self.tableView.contentOffset = CGPointMake(0, 44);
_searchBarRevealed = YES;
}
}
【讨论】:
TAToolbarHeight() 是什么?我假设它返回 44 的值?