我正在调用以下函数以在 viewDidLoad 中成功隐藏我的搜索栏:
- (void)hideSearchBar {
CGRect newBounds = self.tableView.bounds;
newBounds.origin.y = newBounds.origin.y + _searchBar.bounds.size.height;
self.tableView.bounds = newBounds;
}
但如果我在 (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
中调用完全相同的函数,我的 TableView 的第一行将与导航栏重叠。为什么这种重叠仅在从 searchBarTextDidEndEditing
调用隐藏函数时发生?
最佳答案
来自this question的回答帮助我意识到这在某种程度上与半透明的导航栏有关。当我将导航栏半透明设置为否时,我遇到了问题。当我停止将其设置为 NO 时,它工作正常。
关于ios - 在 iOS 7 中隐藏 UISearchBar 裁剪顶行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22703902/