resultSearchController

resultSearchController

我正在尝试使用https://www.thorntech.com/2016/01/how-to-search-for-location-using-apples-mapkit/的教程来构建搜索功能
我需要更改他的代码
因为从图片中可以看到,如果我执行navigationitem.titleview,加号按钮就会消失。我想在搜索时使用搜索栏,但找不到方法

 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
ios - 如何确定搜索栏的位置-LMLPHP

最佳答案

代替

navigationItem.titleView = resultSearchController?.searchBar
尝试
navigationItem.searchController = resultSearchController

07-24 18:30