【发布时间】:2016-09-22 12:30:10
【问题描述】:
我用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)
}
但我无法更改文本。
【问题讨论】:
-
您是否尝试更改上面屏幕截图中显示“搜索”的字符串?而且,
showSearchController(sender:)当前是否已连接到放大镜栏按钮项?如果是这样,那么您想更改self的title我相信。其中self是实现showSearchController(sender:)的视图控制器。 -
是的,我想更改标题本身你能给出你所说的代码吗?(with showSearchController (sender:)
标签: swift xcode swift2 navigationbar uisearchcontroller