1

I am using this library: https://github.com/xmartlabs/XLPagerTabStrip

My problem is that I can't resolve an issue with adding a UISearchController for one of ButtonBarPagerTabStripViewController child viewController - UITableViewController.

The searchBar does not appear when trying to add it under iOS 11+ like this:

navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true

and when trying to add UISearchBar to tableView as this:

tableView.tableHeaderView = searchController.searchBar

then after tapping into the search field the whole UISearchBar disappears.

Do you know any proper way how to implement UISearchController in a UITableViewController with ButtonBarPagerTabStripViewController as a one of childs?

Andrea Mugnaini
  • 8,880
  • 3
  • 34
  • 49
piotr_ch
  • 458
  • 2
  • 5
  • 17

2 Answers2

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
0

Put this code in the container controller, the one that extends ButtonBarPagerTabStripViewController

definesPresentationContext = true 

and put this code in the Child View Controllers

definesPresentationContext = false
Kelvin Tan
  • 900
  • 1
  • 11
  • 31