IOS11 UISearchBar missing in UINavigationBar when embedded in UISplitViewController

Strange things happen when using the new iOS 11 method navigationItem.searchControllerin a detailed view UISplitViewController.

searchBarpartially appears as an empty space in the first view, and then appears in the wrong UITableViewController, but corrects itself after a few taps and protrusions UITableViewController.

I used searchBarto tableHeaderView, but I changed the code as recommended by WWDC:

if (@available(iOS 11.0, *)) {
    self.navigationItem.searchController = self.searchController;
    self.navigationItem.hidesSearchBarWhenScrolling = NO;
} else {
    self.tableView.tableHeaderView = self.searchController.searchBar;
}

This example uses a standard code example (default project for UISplitViewControllerand Apple demo UISearchControllerupdated for iOS 11 (using one UITableViewController)).

The initial view containing searchControlleris as follows:

enter image description here

UITableView, :

enter image description here

UITableView - , :

enter image description here

enter image description here

, Apple UISearchController, - . , UISplitViewController . , UINavigationController . , sek UINavigationController - ( ). segue to modal .

enter image description here

, : UISplitViewController UISearchController UISearchBar

, ( : searchControllerDemo)

, . .

+1

Source: https://habr.com/ru/post/1687462/