uisearchcontroller

UISearchController iOS 11 Customization

空扰寡人 提交于 2019-12-03 00:20:21
问题 I had been using the following code prior iOS 11 to customize the appearance of the UISearchController search bar: var searchController = UISearchController(searchResultsController: nil) searchController.searchBar.setDefaultSearchBar() searchController.searchResultsUpdater = self if #available(iOS 11.0, *) { navigationItem.searchController = searchController } else { tableView.tableHeaderView = searchController.searchBar } extension UISearchBar { func setDefaultSearchBar() { self.tintColor =

How to add scope buttons in a UISearchController embedded in UINavigationController

孤者浪人 提交于 2019-12-02 09:32:35
I have an App that is presenting a MKMapView embedded in a UINavigationController. In the UINavigationController I have put a UISearchController. When the User touch the UISearchController it displays a UITableViewController. It works well while I'm not adding the Scope button in the UISearchController. Here the screenshot of the UISearchController in the UINavigationController when I start the App. Next when I touch the UISearchController, it displays the UITableViewController and scope button. Here we can already see there's an issue with the scope button because they are not well integrated

Apply NSPredicate on [(String, Array<String>)]

▼魔方 西西 提交于 2019-12-02 06:20:57
问题 I have data stored in this fashion, var data = [(String, Array<String>)]() Example Data: [(A, [Apple, Andy, Android]), (B, [Banana, Breakfast])] I am trying to apply a search filter on this data by using Predicate, Here is what I am tried and failed, func updateSearchResultsForSearchController(searchController: UISearchController) { let searchPredicate = NSPredicate(format: "SELF CONTAINS[c] %@", searchController.searchBar.text) let array = (data as NSArray).filteredArrayUsingPredicate

Using AutoLayout programmatically for search bar and UITableView

試著忘記壹切 提交于 2019-12-01 23:20:19
问题 I have a container view that is nearly the full screen sans the status bar. I then created a UISearchController and a UITableView. I am using ios 9 and doing things programmatically. The bug I am having is when the search bar is touched, the scope options open beneath it but the tableview doesn't slide down correctly. How do I fix this? The code in my viewDidLoad is: // Search controller self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; self

Using AutoLayout programmatically for search bar and UITableView

巧了我就是萌 提交于 2019-12-01 22:34:04
I have a container view that is nearly the full screen sans the status bar. I then created a UISearchController and a UITableView. I am using ios 9 and doing things programmatically. The bug I am having is when the search bar is touched, the scope options open beneath it but the tableview doesn't slide down correctly. How do I fix this? The code in my viewDidLoad is: // Search controller self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; self.searchController.searchResultsUpdater = self; self.searchController.dimsBackgroundDuringPresentation = NO; self

how to change uitextfield color in searchcontroller?

我们两清 提交于 2019-12-01 21:46:54
问题 i have embedded SearchController in navigation bar . How to Change UITextField Color The one which Holds search String To White .? 回答1: This will help you to achieve, what you want. Just apply your color combination in this code and see. if #available(iOS 11.0, *) { let sc = UISearchController(searchResultsController: nil) sc.delegate = self let scb = sc.searchBar scb.tintColor = UIColor.white scb.barTintColor = UIColor.white if let textfield = scb.value(forKey: "searchField") as? UITextField

My UISearchBar in UISearchController disappear when I start searching. Why?

烈酒焚心 提交于 2019-12-01 18:04:28
This is how I setup my UIsearchController private func setupSearchController() { let searchResultsController = storyboard!.instantiateViewControllerWithIdentifier(DBSearchOptionControllerIdentifier) as! DBSearchOptionController searchController = UISearchController(searchResultsController: searchResultsController) let frame = searchController.searchBar.frame searchController.searchBar.frame = CGRectMake(0, 50, view.bounds.size.width, 44.0) searchController.searchResultsUpdater = self view.addSubview(searchController.searchBar) searchController.searchBar.text = "mmm" view.bringSubviewToFront

Swift: Search bar created at Auto Focus

大憨熊 提交于 2019-12-01 13:08:13
I am creating a table view and a search bar by clicking on a button.But I need the search bar to appear at Auto Focus ( where the user enters text immediately with no need to click inside the search bar). How can I do that ? try this @IBOutlet weak var searchBar: UISearchBar! override func viewDidLoad() { super.viewDidLoad() searchBar.becomeFirstResponder() } This should do it. override func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) searchController.active = true } ... extension GDSearchTableViewController: UISearchControllerDelegate { func didPresentSearchController

Swift: Search bar created at Auto Focus

孤人 提交于 2019-12-01 09:38:54
问题 I am creating a table view and a search bar by clicking on a button.But I need the search bar to appear at Auto Focus ( where the user enters text immediately with no need to click inside the search bar). How can I do that ? 回答1: try this @IBOutlet weak var searchBar: UISearchBar! override func viewDidLoad() { super.viewDidLoad() searchBar.becomeFirstResponder() } 回答2: This should do it. override func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) searchController.active =

UISearchController retain issue

一世执手 提交于 2019-12-01 06:59:40
I am trying to use UISearchController however I confronted with retain issue that I can't solve. MainTableview has two sections. Section 1 Filtered Data based on some Regex Section 2 All Data I added UISearchController to my tableview and attached ResultsTableController as resultsTableController. It works when user search something, ResultsTableController comes forward and because I set tableview delegate to self, selecting item from ResultsTableController calls didSelectRowAtIndexPath in my MainTableViewController. However I have allocation issue if user selects something from