1

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

我的问题是我无法解决为其中一个ButtonBarPagerTabStripViewController子 viewController -添加 UISearchController 的问题UITableViewController

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

navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true

并尝试添加UISearchBartableView这样:

tableView.tableHeaderView = searchController.searchBar

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

您知道如何UISearchController在一个孩子UITableViewController中实施任何正确的方法吗?ButtonBarPagerTabStripViewController

4

2 回答 2

0

Seems like an overdue answer but hopefully will help others who might have the same issue.

adding following properties to your searchbar fixes the issue:

searchController.hidesNavigationBarDuringPresentation = false
searchController.definesPresentationContext = false
于 2019-10-15T10:32:40.260 回答
0

将此代码放入容器控制器中,即扩展 ButtonBarPagerTabStripViewController 的容器控制器

definesPresentationContext = true 

并将这段代码放在子视图控制器中

definesPresentationContext = false
于 2020-07-31T05:41:25.380 回答