【发布时间】:2015-04-09 15:35:17
【问题描述】:
我正在尝试添加一个 UISearchBar,以便在我单击 m 导航栏中的左侧导航项时调用。
就像这样(图 1): http://i.stack.imgur.com/N4tF7.png
点击按钮后(图 2) http://i.stack.imgur.com/nWNCB.png
我试过这种方法:
@IBAction func searchController2(sender: AnyObject) {
searchController = UISearchController(searchResultsController: nil)
searchController.searchBar.sizeToFit()
tableView.tableHeaderView = searchController.searchBar
definesPresentationContext = true
}
但问题是,当我点击我的按钮时,在我的导航栏和我的tableview之间创建了一个搜索栏,我只想直接调用图像编号2的效果。
这正是我想要的,但我不知道如何将其转换为 swift :
How to Show and Hide UISearchDisplayController's UISearchBar
【问题讨论】:
标签: swift uisearchbar uinavigationitem