Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tvOS: Is there anyway to prevent the search keyboard from collapsing on scroll?

Tags:

So I have a standard setup for setting up a search view in my tvOS app.

let storyboard = UIStoryboard(name: "Main", bundle: nil) guard let resultsController = storyboard.instantiateViewControllerWithIdentifier(SearchResultsViewController.storyboardIdentifier) as! SearchResultsViewController  let searchController = UISearchController(searchResultsController: resultsController) searchController.searchResultsUpdater = resultsController searchController.hidesNavigationBarDuringPresentation = false searchController.searchBar.placeholder = NSLocalizedString("Enter keyword (e.g. iceland)", comment: "")  let searchContainer = CustomUISearchContainerViewController(searchController: searchController) 

And what this is when pushed onto the navigation stack is a view that has the search bar on top and the results below like this

enter image description here

So whenever the results are large and I have to scroll the keyboard collapses and expands again whenever I scroll back up and swipe past the top most results. Is there any way to prevent this behavior? I just want it to stay open all the time. I was thinking of maybe subclassing UISearchController, but I wasn't sure what in there to even replace

like image 992
Programmer Unextraordinair Avatar asked Aug 16 '16 16:08

Programmer Unextraordinair


1 Answers

I'm not sure this is the correct answer but if you do this your search bar will not collapse. I had set up a UICollectionView with a Horizontal scroll and I never had this issue. It may require laying out your view differently, and if you have hundreds of results this may not be the best solution, but it will keep the search bar and its 'keyboard' from going away.

like image 191
Jay V Avatar answered Nov 10 '22 04:11

Jay V