gpt4 book ai didi

ios - 未检测到 searchBarSearchButtonClicked

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

我已经使用嵌入导航栏设置了一个搜索栏。未检测到 func searchBarSearchButtonClicked。我想这样做,以便当用户点击搜索栏时,将调用另一个函数。我删除了一些与这个问题无关的无关代码。可能是什么问题?

class FirstViewController: UIViewController, UISearchBarDelegate {  

var resultSearchController: UISearchController? = nil

override func viewDidLoad() {
super.viewDidLoad()

// set up the search results table
let locationSearchTable = storyboard!.instantiateViewController(withIdentifier: "LocationSearchTable") as! LocationSearchTable

resultSearchController = UISearchController(searchResultsController: locationSearchTable)
resultSearchController?.searchResultsUpdater = locationSearchTable

let searchBar = resultSearchController!.searchBar
searchBar.sizeToFit()
searchBar.placeholder = "Where would you like to go"
navigationItem.titleView = resultSearchController?.searchBar
searchBar.delegate = self

resultSearchController?.hidesNavigationBarDuringPresentation = false
resultSearchController?.dimsBackgroundDuringPresentation = true
definesPresentationContext = true
}

func searchBarSearchButtonClicked(_: UISearchBar) {
// closeMapType()
// self.mapType.transform = .identity
print("it worked")
}
}

最佳答案

当用户点击搜索栏时将调用以下函数:

func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool {
return true
}

当我们点击键盘上的“搜索”按钮时,这将调用

func searchBarSearchButtonClicked(_: UISearchBar)

关于ios - 未检测到 searchBarSearchButtonClicked,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45724981/

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