Cocoa touch 从iOS5到iOS6的TableView和SearchBar行为不同?

Cocoa touch 从iOS5到iOS6的TableView和SearchBar行为不同?,cocoa-touch,uitableview,uisearchbar,hidden,floating,Cocoa Touch,Uitableview,Uisearchbar,Hidden,Floating,在我的应用程序中,我使用UITableView和搜索栏,没有什么特别的。 搜索栏添加为tableHeaderView self.searchDisplayController.searchBar.delegate = self; self.myTableView.tableHeaderView = self.searchDisplayController.searchBar; 然后我使用下面的代码让搜索栏保持打开状态,这样滚动时它就不会被隐藏 - (void) scrollViewD

在我的应用程序中,我使用UITableView和搜索栏,没有什么特别的。 搜索栏添加为tableHeaderView

self.searchDisplayController.searchBar.delegate = self;
     self.myTableView.tableHeaderView = self.searchDisplayController.searchBar;
然后我使用下面的代码让搜索栏保持打开状态,这样滚动时它就不会被隐藏

- (void) scrollViewDidScroll:(UIScrollView *)scrollView {

    CGRect tableBounds = self.myTableView.bounds;
    CGRect searchBarFrame = self.searchDisplayController.searchBar.frame;

    self.searchDisplayController.searchBar.frame = CGRectMake(tableBounds.origin.x, tableBounds.origin.y, searchBarFrame.size.width, searchBarFrame.size.height);
} 
这在iOS5和iOS5.1中运行良好,但在iOS6中不起作用,但我不知道发生了什么变化,有人有什么想法吗

我们将不胜感激

iOS5和iOS5.1中的搜索栏

iOS6中的搜索栏被隐藏

我不知道为什么会改变,但在iOS 6上实现这一点非常简单


不要将
UISearchBar
设置为
tableHeaderView
,而是使用普通的
UIView
,然后将搜索栏添加为该视图的子视图。

我不确定为什么会更改它,但在iOS 6上实现这一点非常简单


不要将
UISearchBar
设置为
tableHeaderView
,而是使用普通的
UIView
,然后将搜索栏添加为该视图的子视图。

Yep-我看到了同样的情况。可能与自动布局有关。你解决过吗?是的,我也看到了同样的事情。可能与自动布局有关。你解决过吗?