gpt4 book ai didi

ios - 如何确定搜索栏的位置

转载 作者:行者123 更新时间:2023-12-01 19:30:11 29 4
gpt4 key购买 nike

我正在尝试使用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
enter image description here

最佳答案

代替

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

关于ios - 如何确定搜索栏的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63322673/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com