2011-10-10 36 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

是的,对不起,我的内部功能 –

相关问题