【发布时间】:2016-07-26 03:11:01
【问题描述】:
我目前正在尝试为 iOS 应用开发自定义搜索。
我已经设法让搜索控制器出现并且搜索栏正常显示,尽管我唯一的问题是我需要后退按钮出现在导航栏的右侧而不是左侧,见下文
(你可以看到后退按钮在左边,但我需要它在右边) http://imgur.com/qLPoIfG
这是我的代码:
import UIKit
类 SearchTop10Controller: UITableViewController, UISearchResultsUpdating {
override func viewDidLoad() {
super.viewDidLoad()
let searchController = UISearchController(searchResultsController: self);
self.definesPresentationContext = true;
searchController.searchResultsUpdater = self;
// searchController.hidesNavigationBarDuringPresentation = true;
searchController.dimsBackgroundDuringPresentation = false;
searchController.searchBar.sizeToFit();
self.navigationItem.titleView = searchController.searchBar;
self.tableView.tableHeaderView = searchController.searchBar;
}
override func viewDidAppear(animated: Bool) {
}
func updateSearchResultsForSearchController(searchController: UISearchController) {
//do whatever with searchController here.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
【问题讨论】:
-
不要编辑您的代码以包含您的固定代码(没有问题)。单击旁边的复选标记,将帮助您找到解决方案的答案标记为答案。
-
我会说,如果这是你想在商店里买到的东西,Apple 通常非常反对违反标准(即它在右边而不是左边)。