1

I am trying to create a UINavigationController with a UISearchController similar to the one in this screenshot.

However, it ends up being rendered like the following screenshot:

I am not sure why the gap is being rendered.

I have the following code to set up the UISearchController:

func configureSearchController() {
    let searchController = UISearchController()
    searchController.searchResultsUpdater = self
    searchController.searchBar.delegate = self
    searchController.searchBar.placeholder = "Search for a username"
    searchController.obscuresBackgroundDuringPresentation = false
    navigationItem.searchController = searchController
}

1 Answers1

0

The issue you're having is that you have nested NavigationViewControllers. You're probably wrapping the tab bar in a navigation controller, and then each tab as well. Remove the outer one and you should be fine.

In summary it should go:

  1. root view = UITabBarController()
  2. Each tab of UITabBarController() is wrapped in a UINavigationController()
  3. Inside each UINavigationController() is the actual view you want to show (InstaKidsVC in your case)
Richard Witherspoon
  • 4,082
  • 3
  • 17
  • 33