我正在使用 UISearchController
并且 UISearchBar
也有一个范围栏。搜索栏作为 subview 添加到 UItableView
上方的 UIView
中。我这样做是因为我希望搜索栏即使在滚动 tableview 时也始终可见。
问题是范围栏与第一个表格 View 单元格重叠
Storyboard
范围栏与表格 View 单元格重叠
如何防止这种重叠?我无法在导航栏中显示搜索栏,因为放置在导航栏中的范围栏不会显示。
最佳答案
这对我有用:
在 tableview 标题中有 Search Display Controller 和 SearchBar。在您的 TableViewController 中添加 heightForHeaderInSection
。
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 44; //I used the 44, the height of SearchBar
}
在您的情况下,您还需要添加范围栏高度。 现在它将始终保持基本高度。
关于uitableview - UISearchController 的搜索栏与第一个 tableview 单元格重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29264571/