uisearchcontroller

Swift - Search using UISearchController and NSPredicate with an array of structs

核能气质少年 提交于 2019-12-25 06:47:05
问题 Currently I'm trying to set up a search bar for my tableView. I want to filter the user's input with NSPredicate to display filtered data from an array of struct objects. But when I try to call .filteredArrayUsingPredicate() on such an array, I get the following error [Course] is not convertible to 'NSArray' . Below is my code and a link to the repo. I'm also open to any better methods of approach. import UIKit import SwiftyJSON class CourseTableViewController: UITableViewController,

How do I dismiss a UISearchController view?

核能气质少年 提交于 2019-12-25 04:55:12
问题 Context: There's a map view with a UISearchController implemented. The search controller displays its results in a different table view controller I found this answer which explains how to dismiss the search controller within the same view. However, my results page is a different view than its origin page. I have let resultsPage = ResultsTableViewController() let searchController = UISearchController(searchResultsController: resultsPage) So now when the search controller gets results, it

UISearchController's searchBar doesn't fill full width

这一生的挚爱 提交于 2019-12-24 15:49:04
问题 EDIT: I am using Autolayout. I have a problem filling the full width of my screen with a UISearchController's searchBar. My setup is like so : I have a UIViewController. Inside, I have all my elements separated. There is a UITableView displaying the results. Since I had trouble with the searchBar overlapping the status bar, I created a plain UIView that has constraints so that it lives under the status bar and fills the full width of the UIViewController. This is a method that I have seen

UISearchController misplaces UISearchBar

别说谁变了你拦得住时间么 提交于 2019-12-24 06:45:21
问题 I am using the UISearchController on a modal page to allow a user to search some data. The page uses a table view controller design and the searchBar is in a tableViewCell. When the user taps on the searchBar, the UISearchController animates the layout to slide the table header to the top of the page and moves the searchbar. However it does not end up in the right place. It does not move sufficiently up. Anyone have a suggestion on how to help the UISearchController to position the searchBar

searchBar from UISearchController not showing correctly on split view on iPad

北慕城南 提交于 2019-12-24 04:25:06
问题 Today I migrated my code from UISearchDisplayController (deprecated in iOS 8) to UISearchController and the search bar now is not always showing correctly. I'm using a UISplitViewController that is ALWAYS showing the master column (so also on an iPad/iPhone6+ in portrait). I prefer this visually over the user having to swipe from left to right to see that column. If open the application an tap on an item in the master column, the detail column loads and the searchBar is resized appropriately.

Change UISearchBar background image in iOS11

拥有回忆 提交于 2019-12-23 20:51:47
问题 I want to change my UISearchBar background image. When adding it as the header view in my UITableView it works perfectly fine. However, when I want to change it for the SearchBar being set as the searchController of the navigationItem it won´t change the background image. I´m using: self.searchBar.searchBar.setBackgroundImage(UIImage(named: "#IMAGENAME")?.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch), for: .any, barMetrics: UIBarMetrics.default) Does anybody know

UISearchcontroller searchbar delegate not working

↘锁芯ラ 提交于 2019-12-22 11:24:31
问题 class PlaceSelectorViewController: UIViewController, GMSAutocompleteResultsViewControllerDelegate, UISearchBarDelegate { I have included searchbar delegate searchController?.searchBar.delegate = self and I have set the delegate. But method func searchBarCancelButtonClicked(_ searchBar: UISearchBar) { stopHighlight() } doesn't happen. Delegate has set properly and stopHighlight() is a real function 回答1: Make delegate of searchbar in viewdidload method. override func viewDidLoad() { super

Wrong placement of search text field inside search bar on iOS 11

梦想与她 提交于 2019-12-22 10:44:39
问题 I am using UISearchController as part of navigation bar using the new APIs introduced in iOS 11. I am using it in the following manner in my ViewController's viewDidLoad - (void)viewDidLoad { [super viewDidLoad]; [_table setDataSource:self]; [_table setDelegate:self]; searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; [self.navigationItem setSearchController:searchController]; [self.navigationItem setHidesSearchBarWhenScrolling:NO]; [searchController

Navigation bar disappears when typing in UISearchController text field

家住魔仙堡 提交于 2019-12-22 04:32:49
问题 I'm trying to figure out why my whole navigation bar disappears when I start typing in the UISearchController.searchBar It loads properly and animates properly, but I lose the active NavBar when I start typing. Here's the code to load the searchController from viewDidLoad: UITableViewController *searchResultsController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain]; searchResultsController.tableView.dataSource = self; searchResultsController.tableView.delegate = self;

UISearchBar width doesn't change when its embedded inside a UINavigationBar

落爺英雄遲暮 提交于 2019-12-21 17:32:05
问题 I'm experimenting with the new UISearchController API introduced in iOS 8. Although the API is new, it uses the same old UISearchBar . I added it to the UINavigationController 's titleView . import UIKit class ViewController: UIViewController, UISearchBarDelegate { override func viewDidLoad() { super.viewDidLoad() let searchController = UISearchController(searchResultsController: nil) searchController.hidesNavigationBarDuringPresentation = false searchController