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
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With