Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么我的UISearchController渲染不正确?_Ios_Swift_Uinavigationcontroller_Uisearchcontroller - Fatal编程技术网

Ios 为什么我的UISearchController渲染不正确?

Ios 为什么我的UISearchController渲染不正确?,ios,swift,uinavigationcontroller,uisearchcontroller,Ios,Swift,Uinavigationcontroller,Uisearchcontroller,我正在尝试创建一个UINavigationController,其UISearchController与此屏幕截图中的类似 但是,它最终呈现为以下屏幕截图: 我不知道为什么会出现这种差距 我有以下代码来设置UISearchController: func configureSearchController() { let searchController = UISearchController() searchController.searchResultsUpdater

我正在尝试创建一个
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
}

您遇到的问题是您有嵌套的NavigationViewController。您可能正在将选项卡栏包装到导航控制器中,然后再包装每个选项卡。拆下外面的那个,你会没事的

总之,它应该是:

  • 根视图=UITabBarController()
  • UITabBarController()的每个选项卡都包装在一个UINavigationController()中
  • 每个UINavigationController()中都有您想要显示的实际视图(在您的示例中为InstaKidsVC)

  • 您遇到的问题是您有嵌套的NavigationViewController。您可能正在将选项卡栏包装到导航控制器中,然后再包装每个选项卡。拆下外面的那个,你会没事的

    总之,它应该是:

  • 根视图=UITabBarController()
  • UITabBarController()的每个选项卡都包装在一个UINavigationController()中
  • 每个UINavigationController()中都有您想要显示的实际视图(在您的示例中为InstaKidsVC)

  • 不幸的是,这可能与我无关。不幸的是,这可能与我无关。