gpt4 book ai didi

swift - 如何更改导航栏(UISearchController)的文本?

转载 作者:行者123 更新时间:2023-11-28 06:33:31 26 4
gpt4 key购买 nike

我用 UISearchController 创建了一个导航栏。

下面是我的代码:

@IBAction func showSearchController(sender: AnyObject) {
let searchController = UISearchController(searchResultsController: searchResultController)
searchController.searchBar.delegate = self
/*
searchController.searchBar.placeholder = "hhhhhhhhhhh"
searchController.navigationItem.title = "hhhhhhhhhhh"
searchController.navigationController?.navigationBar.topItem?.title = "hhhhhhhh" -->i try these codes for to change*/

self.presentViewController(searchController, animated: true, completion: nil)
}

但我无法更改文本。

enter image description here

最佳答案

var searchTextField = searchController.searchBar.valueForKey("_searchField") as! UITextField
searchTextField.placeholder = "Your Custom Text"

enter image description here使用它来更改您的占位符文本

关于swift - 如何更改导航栏(UISearchController)的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39639117/

26 4 0