我为图片感到抱歉,但我不知道更好的方式来解释我的问题。这是我启动应用程序时的视图,一切正常。

这是当我旋转手机的时候,搜索栏的顶部现在有点在导航栏下面。

我开始搜索并取消它。

现在搜索栏没有被导航栏覆盖,但是导航栏的高度变小了。

当我返回到垂直视图时,导航栏仍然很小,并且在它下面有一个黑洞。

我不知道为什么会这样,有什么帮助吗?
这是我如何创建和添加搜索栏的代码:
- (void) loadView
{
[super loadView];
sBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0,0,320,45)];
sBar.delegate = self;
sBar.placeholder = @"Search";
self.tableView.tableHeaderView = sBar;
UISearchDisplayController *searchDC = [[UISearchDisplayController alloc] initWithSearchBar:sBar contentsController:self];
self.searchDisplayController = searchDC;
searchDC.delegate = self;
searchDC.searchResultsDataSource = self;
searchDC.searchResultsDelegate = self;
[sBar release];
[searchDC release];
}我没有改变任何专门用于导航或搜索栏的旋转方法。
发布于 2011-01-14 18:22:18
验证以下位置中的所有视图框:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation如果它们不正常,设置正确的帧。
发布于 2011-05-12 04:43:19
最简单的解决方案是在UITableView报头中添加UISearchBar。在这种情况下,所有员工都将开箱即用。
在视图和旋转之间切换时,设置边框可能会导致UISearchBar宽度问题。我在基于标签的应用程序中遇到了这个问题。是的,测试用例不是很容易重现,但它仍然是一个bug。
https://stackoverflow.com/questions/4689461
复制相似问题