Car*_*rlo 2 uitableview uisearchbar ios swift uisearchcontroller
我有一个简单的tableViewController,一个searchBar带范围和一个navigationBar.
当我点击我的searchBar我看到我的范围和所有工作。然后我单击一行并转到我DetailPage的搜索栏并没有隐藏(我不知道为什么)。
所以我点击取消,然后我回到我的tableView. 当我返回到我的 tableView 时,我SearchBar和我的NavigationBar.
这是我的代码:
self.resultSearchController = ({
let controller = UISearchController(searchResultsController: nil)
controller.searchResultsUpdater = self
controller.hidesNavigationBarDuringPresentation = true
controller.dimsBackgroundDuringPresentation = false
controller.searchBar.sizeToFit()
controller.searchBar.scopeButtonTitles = ["Title", "Author", "Location", "Price", "User"]
self.tableView.tableHeaderView = controller.searchBar
return controller
})()
func updateSearchResults(for searchController: UISearchController)
{
let scopes = resultSearchController.searchBar.scopeButtonTitles
let currentScope = scopes![resultSearchController.searchBar.selectedScopeButtonIndex] as String
filterContentForSearchText(searchText: searchController.searchBar.text!, scope: currentScope)
}
Run Code Online (Sandbox Code Playgroud)
尝试添加
self.automaticallyAdjustsScrollViewInsets = false;
self.extendedLayoutIncludesOpaqueBars = true
Run Code Online (Sandbox Code Playgroud)
在viewDidload。
| 归档时间: |
|
| 查看次数: |
2409 次 |
| 最近记录: |