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

1

25

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

Dupont answered 16/8, 2016 at 16:28 Comment(1)
Have you ever solved this?Jack
E
0

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.

Erle answered 25/7, 2018 at 13:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.