tvOS 14 - UISearchController dismissing the entire UITabController

164 Views Asked by At

I have been having several issues with the UISearchController since the first day, but I always managed to work around it. With tvOS 14 however, I have now a problem that I don't understand:

  1. I present my tab controller
  2. From one of the viewController of the tabController, I present the searchController;
  3. I press menu to dismiss it.

RESULT: the searchController and the whole tabController are dismissed.

EXPECTED: only the searchController should be dismissed and go back to the viewController I presented it from.

This only happens in tvOS14, in tvOS13.X works well.

I tried to check the presentingViewController before dismissing it, and for some reason it is the tabController instead of the viewController I presented it from. This is the piece of code to present:

    UISearchController *searchController = [[UISearchController alloc] initWithSearchResultsController:resultVC];
    searchController.searchResultsUpdater = resultVC;
    searchController.delegate = resultVC;
    searchController.searchBar.delegate = resultVC;
    
    [strongSelf presentViewController:searchController animated:YES completion:nil];

and when I press menu, or execute this code from a button's action in the resultVC:

[self dismissViewControllerAnimated:YES completion:nil];

I get the result explained above. Same result if I do:

[self.searchController dismissViewControllerAnimated:YES completion:nil];

I also tried wrapping everything into a UISearchContainerViewController, but the result is the same.

Does anyone have any clue?

1

There are 1 best solutions below

0
On

I opened a bug for Apple.

In the meantime, I solved creating a new UIViewController, presenting the UISearchViewController there, and then presenting this new view controller. Only for tvOS14.

To dismiss it, I dismiss first the search controller and then the new view controller.

To handle the tap on the "menu" button, I overridden pressesBegan on the result view controller and in the search view controller (through a custom class).