2011-10-10 35 views

回答

7

我的解決辦法是在viewWillAppear:animted

[my_table_view setContentOffset:CGPointMake(0, searchController.searchBar.bounds.size.height)]; 

UPDATE我們應該得到的,而不是使用固定的值UISearchBar高度。

+1

高度爲44分 –

+0

感謝。我會更新答案。 – Raptor

+1

不要使用這樣的常量。改爲使用'searchController.searchBar.bounds.height'。未來iOS版本的高度可能會發生變化,這會破壞你的代碼,但不會是這個。 –

1

這裏是我如何隱藏在視圖中的搜索欄會出現。這種剪切將確保搜索欄最初是隱藏的,只有在第一次查看時纔會出現調用。搜索欄的

- (void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 

    //hide search bar 
    if (_searchBarRevealed == NO) { 
     self.tableView.contentOffset = CGPointMake(0, 44); 
     _searchBarRevealed = YES; 
    } 
} 
+0

'TAToolbarHeight()'是什麼?我假設它返回'44'的值? – Raptor

+0

是的,對不起,我的內部功能 –

相關問題