如何最初隱藏UITableView的UISearchDisplayController?我只想讓用戶向上滾動來查看UISearchBar。最初隱藏UITableView的UISearchDisplayController(iOS SDK)?
更新:我想滾動UITableView 40px較低,以便UISearchBar可以從用戶「隱藏」。
如何最初隱藏UITableView的UISearchDisplayController?我只想讓用戶向上滾動來查看UISearchBar。最初隱藏UITableView的UISearchDisplayController(iOS SDK)?
更新:我想滾動UITableView 40px較低,以便UISearchBar可以從用戶「隱藏」。
我的解決辦法是在viewWillAppear:animted
:
[my_table_view setContentOffset:CGPointMake(0, searchController.searchBar.bounds.size.height)];
UPDATE我們應該得到的,而不是使用固定的值UISearchBar
高度。
這裏是我如何隱藏在視圖中的搜索欄會出現。這種剪切將確保搜索欄最初是隱藏的,只有在第一次查看時纔會出現調用。搜索欄的
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//hide search bar
if (_searchBarRevealed == NO) {
self.tableView.contentOffset = CGPointMake(0, 44);
_searchBarRevealed = YES;
}
}
'TAToolbarHeight()'是什麼?我假設它返回'44'的值? – Raptor
是的,對不起,我的內部功能 –
高度爲44分 –
感謝。我會更新答案。 – Raptor
不要使用這樣的常量。改爲使用'searchController.searchBar.bounds.height'。未來iOS版本的高度可能會發生變化,這會破壞你的代碼,但不會是這個。 –