当我将UISearchController搜索栏中的占位符文本更新为比搜索栏更宽的内容时,搜索图标会出现这种情况:
我通过调用viewDidLoad
中的以下方法添加了UISearchController和搜索栏:
private func initSearchController() {
searchResultsController = UITableViewController()
searchResultsController.tableView.backgroundColor = UIColor(red: 51/255, green: 51/255, blue: 51/255, alpha: 1.0)
searchController = UISearchController(searchResultsController: searchResultsController)
searchResultsController.tableView.rowHeight = 50
let textFieldInsideSearchBar = searchController.searchBar.valueForKey("searchField") as? UITextField
textFieldInsideSearchBar?.textColor = UIColor.whiteColor()
searchController.searchBar.sizeToFit()
searchController.searchBar.placeholder = "SOL Southwest Kitchen & Tequila Bar"
searchController.hidesNavigationBarDuringPresentation = false
searchController.dimsBackgroundDuringPresentation = true
searchController.searchBar.searchBarStyle = .Minimal
navigationItem.titleView = searchController.searchBar
definesPresentationContext = true
searchController.searchResultsUpdater = self
searchResultsController.tableView.dataSource = self
searchResultsController.tableView.delegate = self
searchController.searchBar.delegate = self
}
是什么给出的?另外,无论如何要删除后退按钮和搜索栏之间的奇怪空隙?如果有帮助,此视图是导航控制器中的第二个视图控制器。使用iOS9和Swift 2.1。谢谢!
答案 0 :(得分:2)
除非使用按钮,图像和文本字段创建自定义搜索栏,否则似乎无法进行此操作。