为什么我的UISearchController无法正确呈现?

问题描述 投票:1回答:1

我正在尝试使用类似于此屏幕截图中的UINavigationController创建一个UISearchController

但是,它最终像下面的屏幕截图一样呈现:

我不确定为什么会出现间隙。

我有以下代码来设置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
}
ios swift uinavigationcontroller uisearchcontroller
1个回答
0
投票

您遇到的问题是您嵌套了NavigationViewControllers。您可能会将标签栏包装在导航控制器中,然后再包装每个标签。拆下外面的那一个就可以了。

总的来说,应该去:

  1. 根视图= UITabBarController()
  2. [UITabBarController()的每个选项卡都包装在UINavigationController()中
  3. 在每个UINavigationController()内部是您想要显示的实际视图(在您的情况下为InstaKidsVC)
© www.soinside.com 2019 - 2024. All rights reserved.