Ios 如何确定搜索栏的位置

Ios 如何确定搜索栏的位置,ios,swift,Ios,Swift,我正在尝试使用来自的教程构建搜索函数 我需要更改他的密码 因为正如您从图片中看到的,如果我执行navigationitem.titleviewplus按钮就会消失。我想在搜索时使用搜索栏,但找不到方法 let searchBar = resultSearchController!.searchBar searchBar.sizeToFit() searchBar.placeholder = "Search for places"

我正在尝试使用来自的教程构建搜索函数 我需要更改他的密码 因为正如您从图片中看到的,如果我执行
navigationitem.titleview
plus按钮就会消失。我想在搜索时使用搜索栏,但找不到方法

 let searchBar = resultSearchController!.searchBar
        searchBar.sizeToFit()
        searchBar.placeholder = "Search for places"
        navigationItem.titleView = resultSearchController?.searchBar
        resultSearchController?.hidesNavigationBarDuringPresentation = false
        resultSearchController?.dimsBackgroundDuringPresentation = true
        definesPresentationContext = true
        locationSearchTable.mapView = mapView
        locationSearchTable.handleMapSearchDelegate = self
而不是

navigationItem.titleView = resultSearchController?.searchBar
试一试

navigationItem.searchController = resultSearchController