ios - 如何使搜索栏不随表格 View 一起滚动?

标签 ios swift uitableview uisearchdisplaycontroller

<分区>

我想做一个这样的搜索栏。

enter image description here

当我向下滚动时,联系人应用程序中的搜索栏保持不变。我想用 It doesn't scroll down along with table view 这个属性制作一个搜索栏。我在 TableView Controller 中做了我的应用程序。这是我在 TableView Controller 中的代码。

myTableViewController(在我的 viewDidLoad 函数中):

searchController = UISearchController(searchResultsController: nil)
searchController.hidesNavigationBarDuringPresentation = false
searchController.searchBar.searchBarStyle = UISearchBarStyle.Prominent
searchController.searchBar.sizeToFit()
tableView.tableHeaderView = searchController.searchBar
definesPresentationContext = true
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false

由于这段代码,它应该像联系中的搜索栏一样工作

tableView.tableHeaderView = searchController.searchBar

我做错了什么吗?如果不是,那么如何使我的搜索栏不随 TableView (在 TableView Controller 中)向下滚动?

最佳答案

代替搜索栏 TableView 中,制作搜索栏 TableView 。因此,当表格 View 滚动时,搜索栏就在那里。

关于ios - 如何使搜索栏不随表格 View 一起滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32080112/

相关文章:

ios - 如何从 Store Kit Framework 获取当前价格等级?

IOS加速度计/陀螺仪问题

ios - 将 MultipeerConnectivity Framework 与 WiFly 模型一起使用?

Swift - 转换 [AnyObject]!到[协议(protocol)]!直接地

ios - Firebase 和后台运行的预定通知

iphone - ASIHTTPRequest POST iPhone

ios - 从 iOS 应用程序上传文件到服务器

swift - 如何快速更改表格 View 中文本的颜色?

ios - UITableView 的 tableViewHeader 和 tableViewCells 重叠,直到调用 reloadData

ios - 问题检测按钮 cellForRowAt