iOS 13 UIBarButtonItem not clickable and overlapping UINavigationBars when using UISearchController

The view debugger reveals what’s going on with this bug. The contents of the navigation bar are being copied. Here’s what the navigation bar looks like before you show the search: And here’s what it looks like afterwards: The two replicant views and the extra UILabel are the problem. I don’t know what they’re doing … Read more

UISearchController: show results even when search bar is empty

You can simply implement the UISearchResultsUpdating protocol and set the results controller view to always show in updateSearchResultsForSearchController: func updateSearchResultsForSearchController(searchController: UISearchController) { // Always show the search result controller searchController.searchResultsController?.view.hidden = false // Update your search results data and reload data .. } This works because the method is called even when the search bar … Read more

UISearchBar presented by UISearchController in table header view animates too far when active

Old question but I was able to solve this issue by setting self.extendedLayoutIncludesOpaqueBars = YES; on my view controller. I think is issue is caused by having an opaque navigation bar but setting hidesNavigationBarDuringPresentation to NO on your search controller, causing the search bar to incorrectly position itself when focused.

How to implement UISearchController in UITableView – Swift

Yes, the way search works has been radically changed for what I consider to be a better system. The new system is much better and straight to the point for most simple implementations. Using it is pretty straightforward. First, make your class comply with the UISearchResultsUpdating protocol. class MyTableViewController: UITableViewController, UISearchResultsUpdating {} Add it the … Read more

iOS 9 searchBar disappears from table header view when UISearchController is active

I’m not sure what exactly is the problem but I ‘fixed’ it by: self.searchController.hidesNavigationBarDuringPresentation = NO; self.definesPresentationContext = NO; My guess is that UISearchController is doing something funky when it is trying to present as a navigation bar. So, this is a hack but it at least doesn’t block the user. The search bar doesn’t … Read more

Cannot set searchBar as firstResponder

I noticed this issue too. What seems to happen is the call to becomeFirstResponder is done when the searchController is still ‘loading’. If you comment out becomeFirstResponder you notice that there is no difference. So we need a way to call becomeFirstResponder after the searchController is ‘done’ loading. When I looked at various delegate methods … Read more

UISearchController iOS 11 Customization

I just found out how to set them: (with some help of Brandon and Krunal, thanks!) The “Cancel” text: searchController.searchBar.tintColor = .white The search icon: searchController.searchBar.setImage(UIImage(named: “my_search_icon”), for: UISearchBarIcon.search, state: .normal) The clear icon: searchController.searchBar.setImage(UIImage(named: “my_search_icon”), for: UISearchBarIcon.clear, state: .normal) The search text: UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.white] The placeholder: UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).attributedPlaceholder = NSAttributedString(string: “placeholder”, … Read more

tech