ios - XLPagerTabStrip - 如何添加 UISearchController

标签 ios swift uitableview uisearchcontroller xlpagertabstrip

我正在使用这个库:https://github.com/xmartlabs/XLPagerTabStrip

我的问题是我无法解决为 ButtonBarPagerTabStripViewController subview Controller 之一添加 UISearchController - UITableViewController 的问题。

尝试在 iOS 11+ 下添加时,搜索栏不会出现,如下所示:

navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true

当尝试将 UISearchBar 添加到 tableView 时:

tableView.tableHeaderView = searchController.searchBar

然后在点击搜索字段后,整个 UISearchBar 消失了。

您知道如何在 UITableViewController 中将 ButtonBarPagerTabStripViewController 作为子项之一实现 UISearchController 的正确方法吗?

最佳答案

似乎是一个迟来的答案,但希望能帮助其他可能遇到同样问题的人。

将以下属性添加到您的搜索栏可解决此问题:

searchController.hidesNavigationBarDuringPresentation = false
searchController.definesPresentationContext = false

关于ios - XLPagerTabStrip - 如何添加 UISearchController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48205214/

相关文章:

ios - 如何在ios中取消选中tableview上的所有单元格

iphone - 自动标签切换

ios - 即使实现委托(delegate)方法也会出现 "does not conform to JTAppleCalendarViewDelegate"错误

ios - 使用 performBackgroundTask 将多个核心数据插入分派(dispatch)到 NSPersistentContainer 时合并冲突

ios - "Pro Objective-C Design Patterns for iOS"子类化单例困惑

ios - UITableViewCell 圆角问题

ios - 可达性和reachabilityWithHostName

ios - 使用 ML 套件(使用 CMSampleBuffer)从实时视频流中识别文本

ios - Firebase,获得具有特定值(value)的 child 的直接 parent

ios - 在 ViewController 中使用带有外部数据源和 UITableView 的自定义 UITableViewCell