ios - 在 iOS 7 中隐藏 UISearchBar 裁剪顶行

标签 ios iphone uitableview ios7 uisearchbar

我正在调用以下函数以在 viewDidLoad 中成功隐藏我的搜索栏:

- (void)hideSearchBar {
    CGRect newBounds = self.tableView.bounds;
    newBounds.origin.y = newBounds.origin.y + _searchBar.bounds.size.height;
    self.tableView.bounds = newBounds;
}

enter image description here

但如果我在 (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar 中调用完全相同的函数,我的 TableView 的第一行将与导航栏重叠。为什么这种重叠仅在从 searchBarTextDidEndEditing 调用隐藏函数时发生?

enter image description here

最佳答案

来自this question的回答帮助我意识到这在某种程度上与半透明的导航栏有关。当我将导航栏半透明设置为否时,我遇到了问题。当我停止将其设置为 NO 时,它工作正常。

关于ios - 在 iOS 7 中隐藏 UISearchBar 裁剪顶行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22703902/

相关文章:

iphone - 无法调用 UIKeyboard 通知

iphone - 更改重复使用的单元格的类型?

ios - Google Cloud Messaging Bitcode,链接器命令失败

ios - UITableViewCell indexPathForRowAtPoint 总是返回 nil

ios - 如何在 iOS 的 HealthKit 中保存 HKQuantityTypeIdentifierBodyMass 类型的样本

iphone - 后台 iPhone 中的多个异步 HTTP 请求

iphone - 在我将 iPhone 应用程序提交给 Apple 之前,如何获取该应用程序的应用程序 ID?

iphone - 仅在导航弹出后分组 UITableViewCell 上才会出现黑色角

iOS UITableView 偏移刷新控件

ios - 滚动时 UITableViewCell 自动布局抖动的动态单元格高度问题