uisearchbar

iPhone TableView Search XML

只愿长相守 提交于 2019-12-05 05:40:58
问题 I have a question about adding XML to the searchbar in a tableview. I can get all the external XML file to load in the tableview, but when I hit the searchbar up top, and hit a letter, it crashes. I think it's something really simple that I'm doing wrong. In my RootViewController, there's a function called searchTableView. I feel like that's where it's not picking up the search items. I think it's somewhere around the objectForKey:@"title". When I debug, I get this error message also:

How to change border and icons in Search bar (Swift)

本小妞迷上赌 提交于 2019-12-05 05:40:38
问题 I have this: http://postimg.org/image/ag29m3e7d/ and I need this http://postimg.org/image/4bacislw5/ I have to create border or set it by image? How to change search icons(magnifier and X icon) or could I change just colors? Sorry for links but I cannot insert images here. 回答1: To add borders use the views layer property. self.searchBar.layer.borderColor = UIColor.blueColor().CGColor self.searchBar.layer.borderWidth = 1 If you want to add the corner radius to the searchBar: self.searchBar

customizing UISearchBarIconClear for UIControlStateHighlighted does not work

我们两清 提交于 2019-12-05 05:36:59
I have a UISearchBar for which I have set a custom UISearchBarIconClear for UiControlStateNormal. [mySearchBar setImage:myImage forSearchBarIcon:UISearchBarIconClear state:UIControlStateNormal]; This part works as it should but unfortunately when tapping the clear button, it changes from the image I set, to the original default gray one. I have tried setting the image for UIControlStateHighlighted, but apparently that does not work. The documentation actually states Valid states are UIControlStateNormal and UIControlStateDisabled. What's the point of setting a custom button for the default

How to change SearchBar border color

假如想象 提交于 2019-12-05 04:58:36
问题 I would like to change grey border color in my Search Bar to white color. Now it looks like that: I achieved this effect after using this lines of code, but "inside border" is still grey: var searchBar: UISearchController! self.searchBar.searchBar.backgroundColor = UIColor.whiteColor() self.searchBar.searchBar.layer.borderWidth = 3 self.searchBar.searchBar.layer.borderColor = UIColor.whiteColor().CGColor self.searchBar.searchBar.layer.backgroundColor = UIColor.whiteColor().CGColor self

How to change UISearchBar Icon to custom image?

ε祈祈猫儿з 提交于 2019-12-05 02:36:47
Currently, I have the default magnifying glass as my search bar icon. However, I want to put a custom image in its place, particularly this image: Custom Arrow Icon How would I go about changing the search bar default icon to the custom image? you can use setImage function searchBar.setImage(UIImage(named: "your image"), forSearchBarIcon: .Search, state: .Normal) Swift3 searchBar.setImage(UIImage(named: "Image Name"), for: .search, state: .normal) iOSDevCenter Way 1 : As luiyezheng answer, You can change the image of UISearchBar iCon. UISearchBar.appearance().setImage(UIImage(named: "new

Swift Using NSFetchedResultsController and UISearchBarDelegate

扶醉桌前 提交于 2019-12-05 02:32:52
问题 I am looking for a decent solution to this problem. I am wanting to implement some simple search functionality on a TableView that I have. All the examples I have found either use the deprecated UISearchDisplayController or use the new UISearchController but without NSFetchedResultsController Currently this is populated using Core Data / NSFetchedResultsController So far I have managed to get it to a point where I can gather the users' search string (woo!). I am aware that I may need a

How to change the alignment of a UISearchBar according to the input language

若如初见. 提交于 2019-12-05 01:47:44
问题 I would like to be able to input text in either Left-to-Right and Right-to-Left languages into a UISearchBar. This means that once a user has started inputing text in right to left languages, I would like the text alignment to be to the right and vice versa. The question is - Is there any way to catch these events of language switching? Thanks for your help. 回答1: Yes there is. You want to subscribe to UITextInputCurrentInputModeDidChangeNotification . See the UITextInputMode Class Reference.

UISearchBar text color

五迷三道 提交于 2019-12-05 00:19:25
Browsed the documentation and I couldn't find anything to change the color of UISearchBar. Does anybody know how to change it? There isn't any textColor property :/ Thx mkll Works on iOS 7 and later: [[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setDefaultTextAttributes:@{ NSForegroundColorAttributeName : [UIColor whiteColor], NSFontAttributeName : [UIFont systemFontOfSize:15] }]; You may remove unused attribute as well. UPDATE . Due to appearanceWhenContainedIn is deprecated in iOS 9, see the Dishant's answer below: https://stackoverflow.com/a/38893352/2799722 GeoExperts

UISearchBar subview of UITableViewHeader?

只谈情不闲聊 提交于 2019-12-04 23:38:48
问题 I want to add a UISearchBar to a UITableView that already has a header view. When I try and add the search bar to the existing header view it works until I tap on it, at which point I get The view hierarchy is not prepared for the constraint , which appears to be because the search bar is not a direct subview of the tableview so when the UISearchController tries to update the constraints it can't. The only way around this that I've found is making the table view header the search bar, then

Filter Array with UISearchBar

十年热恋 提交于 2019-12-04 22:58:37
I am currently using the following code to filter the array and present the results in my tableView. The problem is that this only returns results if the search matches the exact word. How do I change my array filter to search each character as I type it? let data = ["Mango", "Grape", "Berry", "Orange", "Apple"] var filteredData: [String] = [] filteredData = data.filter({$0 == searchBar.text}) The only way to get "Mango" to show up in my tableView, I have to type Mango in the search bar, typing "Man" doesn't show any results. Try this: filteredData = data.filter { $0.contains(_ other: