How to hide keyboard in UISearchController

I'm trying to replicate the behavior of the keyboard in Apple's UIKit demo app for the tvOS.


I want to configure the UISearchController so that if the search input isn't the focused item,

the keyboard is hidden and only the "text input" field is shown. I also want to do this

programmatically because I don't use storyboards.


Can anyone help me please? I went through the demo app but didn't see how that was configured.

To clarify this problem, it is about a default UIViewController with a UICollectionView inside of it (not a UICollectionViewController). This view controller is set as the result view controller of a UISearchViewController and that is wrapped in a UISearchContainerViewController and that is wrapped in a UINavigationController like explained in this forum to make it work (if i leave any out the view will simply not appear)


Setup code

    _searchResultsViewController = [[SearchResultsViewController alloc] init];
    [_searchResultsViewController setDelegate:self];

    _searchViewController = [[UISearchController alloc] initWithSearchResultsController:_searchResultsViewController];
    [_searchViewController setSearchResultsUpdater:_searchResultsViewController];

    _searchContainerViewController = [[UISearchContainerViewController alloc] initWithSearchController: _searchViewController];
    [_searchContainerViewController setTitle:CRLocalizedString(@"Search")];

    _searchNavigationController = [[UINavigationController alloc] initWithRootViewController:_searchContainerViewController];
}


When we scroll in the UICollectionView while staying on the first row the search bar stays completly visible.

If we scroll down to the second row the search bar scrolls up, due to this the keyboard also moves up, the searchbar is now completly hidden and the keyboard is still visible on the top

Okay it is an bug related to the current focus engine.

The results are displayed in a UICollectionView (vertical) which in their turn have a horizontal UICollectionView in it. Since the primary (vertical) cells cannot have focus (their child cells need to have it) the focus engine and the UISearchViewController somewhere mess up.

My best guess is that they do sometime like focussed view is kind of [cell] of focussed view is part of a scrollview and than get the position of it. but due to the nesting they loss track and do not get the right information.

I really miss Steve Jobs :') he would have never allowed such incomplete software like this to be released.

The UISearchController tvOS input keyboard will sometimes disappear entirely, even with no items in the resultsController, and I can't see a way to bring it back. This is on Simulator and I'm holping this doesn't happen on hardware, though I suspect it does.


This leaves a broken seach engine for our app, since the user will have no way to enter a search string unless they have a physical keyboard for their Apple TV.


Does anyone know how to force the input keyboard to display/redraw?

Anyone got solution for this problem ???
How to hide keyboard in UISearchController
 
 
Q