【发布时间】:2016-08-03 19:52:01
【问题描述】:
我有一个问题:我有一个UIView,其中包含一个UISearchBar 作为UITableView 的标题。问题是每当我点击UISearchBar 时,动画范围按钮就会出现,隐藏表格第一行的一部分。我看了很多类似的问题,但没有一个答案有效。有没有办法向headerView 添加底部约束,以便UITableView 在UISearchBar 被聚焦并被编辑时降低范围按钮视图的高度?
这是我添加UISearchController的代码:
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
definesPresentationContext = true
searchController.searchBar.scopeButtonTitles = ["Groups", "People"]
tableView.tableHeaderView = searchController.searchBar
searchController.searchBar.delegate = self
searchController.searchBar.sizeToFit()
searchController.searchBar.barTintColor = darkGreen
searchController.searchBar.tintColor = yellow
searchController.searchBar.backgroundColor = darkGreen
tableView.sectionHeaderHeight = UITableViewAutomaticDimension
如果您能告诉我如何修复此错误,我将不胜感激!
谢谢!
【问题讨论】:
-
尝试设置definePresentationContext = false
-
设置 definePresentationContext = false 似乎对我有用,尝试使用与您相同的代码。有关此标志的更多信息stackoverflow.com/questions/25445837/…
-
我确实更改了 searchController。 definedPresentationContext = false 但没有任何改变!
-
我将包含 searchController 的表视图控制器的定义PresentationContext 设置为 false.. 而不是 searchController.. 您在上面的代码中将其设置为 true
-
你是对的,对不起。现在我刚刚添加了
definesPresentationContext = false,但仍然无法正常工作。有任何想法吗?感谢您的帮助!
标签: ios xcode swift uitableview uisearchbar