uisearchcontroller

UISearchController change 'Cancel' button title

醉酒当歌 提交于 2019-12-03 14:20:14
How we can change the title of cancel button in search controller? You can change the "Cancel" Button in search bar using this- for (UIView *view in searchBar.subviews) { for (id subview in view.subviews) { if ( [subview isKindOfClass:[UIButton class]] ) { [subview setEnabled:YES]; UIButton *cancelButton = (UIButton*)subview; [cancelButton setTitle:@"hi" forState:UIControlStateNormal]; NSLog(@"enableCancelButton"); return; } } } Burhanuddin Sunelwala The solution provided above could change with new iOS releases. Here is a better approach: [searchBar setValue:@"customString" forKey:@"

Searching through objects in array swift

扶醉桌前 提交于 2019-12-03 13:50:52
I'm trying to create a search function using the UISearchController. However i cant seem to make it work with my Team Object. I've started by creating a Team Object which contain a id, name and shortname. Then i'm retrieving the teamData from a url and adding the Team Objects into an array which is populated into a tableView. This tableView contain a searchController which is suppose to filter the Data, but nothing happens. arrays var teamArray = Array<Team>() var filteredTableData = [String]() GetTeams function func getTeams(url: String) { isApiCalling = true request(.GET, url, parameters:

Add filter button to UISearchController

流过昼夜 提交于 2019-12-03 12:29:45
问题 I want to add a "filter" or "sort" button next to the searchBar inside a UISearchController . I have already tried to add the UIButton and the searchbar into a UIView and set this as my UITableView tableView.tableHeaderView This does not work because the tableView.tableHeaderView get's set back to the UISearchBar only when dismissing the controller. Here is an example of how I want it to look: 回答1: I could create a search filter with a few lines of code. I hope it helps. *I chose the bookmark

UISearchController doesn't hide view when pushed

让人想犯罪 __ 提交于 2019-12-03 10:50:53
I am using UISearchController to display a search bar and results within a UITableView. I managed to set it up correctly, but when I search the results and then select one of the rows in the tableview, and push a new view controller to the navigation stack, I would expect the search bar to not be visible anymore. However, when I try this, the search bar from the first view controller is visible in the 2nd view controller: if (self.searchController == nil) { self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; self.searchController.searchResultsUpdater =

UISearchController: searchBar and scopeBar overlap on first touch event

為{幸葍}努か 提交于 2019-12-03 08:27:44
I'm trying to implement a simple search bar using Apple's latest UISearchController. However I can't seem to get it to work correctly if I use the search bar's scope bar to get a filter choice. The scope bar always shows which I could live with but on the very first touch event the search bar and scope bar overlap. I used Apple's TableView sample code app but it didn't change anything. - (void)viewDidLoad { [super viewDidLoad]; _resultsTableController = [[APLResultsTableController alloc] init]; _searchController = [[UISearchController alloc] initWithSearchResultsController:self

UISearchController changing status bar color on invocation

旧时模样 提交于 2019-12-03 06:24:44
I have the following code in my app, specifically in viewDidLoad: that sets up my UISearchController . self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; self.searchController.searchResultsUpdater = self; self.searchController.hidesNavigationBarDuringPresentation = NO; self.searchController.dimsBackgroundDuringPresentation = NO; self.definesPresentationContext = NO; self.searchController.searchBar.scopeButtonTitles = @[]; self.searchController.searchBar.searchBarStyle = UISearchBarStyleProminent; [_tableView setTableHeaderView:_searchController.searchBar]

Show keyboard automatically when UISearchController is loaded

。_饼干妹妹 提交于 2019-12-03 03:10:59
I created a UISearchController in a table view controller. I segue to this table view controller using a push segue from another view controller. I want the keyboard to show up with the cursor in the search bar as soon as the table view controller is pushed. I made the search controller active in the viewDidLoad method using self.mySearchController.active = true It does make the search controller active but this does not bring up the keyboard nor is the cursor placed in the search bar. I also tried self.mySearchController.searchBar.becomeFirstResponder() This line does not seem to have any

Warning: Attempt to present * on * which is already presenting (null)

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is my first application for iOS. So I have a UIVIewController with a UITableView where I have integrated a UISearchBar and a UISearchController in order to filter TableCells to display override func viewDidLoad() { menuBar.delegate = self table.dataSource = self table.delegate = self let nib = UINib(nibName: "ItemCellTableViewCell", bundle: nil) table.registerNib(nib, forCellReuseIdentifier: "Cell") let searchButton = UIBarButtonItem(barButtonSystemItem: .Search, target: self, action: "search:") menuBar.topItem?.leftBarButtonItem =

Add filter button to UISearchController

安稳与你 提交于 2019-12-03 02:54:43
I want to add a "filter" or "sort" button next to the searchBar inside a UISearchController . I have already tried to add the UIButton and the searchbar into a UIView and set this as my UITableView tableView.tableHeaderView This does not work because the tableView.tableHeaderView get's set back to the UISearchBar only when dismissing the controller. Here is an example of how I want it to look: I could create a search filter with a few lines of code. I hope it helps. *I chose the bookmark button to apply filter icon; because I have already used cancel button for custom action. First, you have

Swift UISearchController wired up in Core Data Project, app runs, but search not updating

拟墨画扇 提交于 2019-12-03 00:24:08
I have been wrestling the past few days with creating a filter in a Swift project for a TableViewController that uses Core Data. I finally figured out I need to use a UISearchController , create an NSPredicate for the searchController.searchBar , etc. I found this post EXTREMELY helpful , but after modeling my TVC after this project, I find "all the lights are on, but nobody's home". I can search, predicate is created in searchBar , add, remove, etc. but the cells don't update for the search. I'm missing something, but I don't know what. Here are the relevant portions of my code. class