uisearchbar

iPhone SDK: UISearchBar: searchBarTextDidEndEditing not firing

浪尽此生 提交于 2019-12-18 06:57:01
问题 I'm implementing a search bar on my table, which should be pretty straight forward. I've got these: - (void)searchBarTextDidBeginEditing:(UISearchBar *)theSearchBar { NSLog(@"searchBarTextDidBeginEditing"); } - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { NSLog(@"The search text is: %@", searchText); } - (void)searchBarTextDidEndEditing:(UISearchBar *)theSearchBar { NSLog(@"searchBarTextDidEndEditing"); [theSearchBar resignFirstResponder]; } And

How to prevent search bar from disappearing on scroll? iOS Swift

笑着哭i 提交于 2019-12-18 05:13:38
问题 I am creating a contact app. I have a scroll bar at the top of my table view. When I scroll down the search bar disapears. How to prevent search bar from disappearing on scroll? I want it to stay at the top of the page at all times like in the first picture. Here is a picture of my storyboard: Here is my view controller code for if the solution is not in storyboard: class ViewController: UITableViewController, UITableViewDataSource, UITableViewDelegate, UISearchResultsUpdating { //manages

How to left align UISearchBar placeholder text

时光毁灭记忆、已成空白 提交于 2019-12-18 04:36:32
问题 I need to make a custom search bar like this. The problem I am having is left aligning the placeholder text, as well as placing the search icon in the right. I have a png of the search icon that I have tried to use in an UIImageView , and set that UIImageView as the rightView of the UISearchBar 's UITextField . This solution has not worked, and I ran out of ideas. Does anyone have a solution? 回答1: Don't use a UISearchBar if you need to do these kinds of customizations. You'll have to make

Display UISearchController's searchbar programmatically

。_饼干妹妹 提交于 2019-12-18 04:14:46
问题 Note 1: This question pertains to adding a UISearchController's search bar outside of the table view it updates - NOT as the table view's header. Note 2: Some trial and error led me to a solution. Please see my answer below. I am new to iOS development and am struggling to work with the UISearchController class. I have a view controller, and in my view controller's view, I plan to have a search bar above a table view. I would like the search bar to be linked to a UISearchController. Since

UITextField within UISearchBar in iOS 7

喜你入骨 提交于 2019-12-18 03:22:13
问题 I am trying to accomplish the same look of my UISearchBar with a TextField within it, as in my iOS 6 app. I have tried to code it in several ways and not yet been successful. The problem is, I am not able to change the TextField's frame in any way since iOS 7. The result is, my TextField takes all the space in the NavigationBar and overrides the UIBarButtonItem (menu button) to the right. See pictures below: iOS 6 code: This is how I coded it in iOS 6, where I could set the TextFields frame

Dynamically Changing Keyboard Type for a UISearchBar

馋奶兔 提交于 2019-12-18 02:46:17
问题 I have an iPhone app that uses a UISearchBar and UISearchDisplayController . The search bar has three scope buttons. I would like the keyboard to be a numeric keypad when a particular scope button is selected, but be a default keyboard when any other scope button is selected. I have implemented the UISearchBarDelegate selectedScopeButtonIndexDidChange:selectedScope method as follows: - (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope { switch

How to make keyboard dismiss when i press out of searchbar on Swift?

天大地大妈咪最大 提交于 2019-12-17 22:37:57
问题 I try to make my searchbar on swift, but i have a problem to dismiss keyboard on screen when i pressed out of searchbar. When i try with textfield it work perfectly fine with this code. override func touchesBegan(touches: NSSet, withEvent event: UIEvent) { self.view.endEditing(true) } It work when i press out of my textfield and then the keyboard is gone. I want to make like that with my searchbar, because when i use searchbar and use the same way like textfield, it doesn't work at all. Any

SearchBar disappears from headerview in iOS 7

℡╲_俬逩灬. 提交于 2019-12-17 22:34:12
问题 I have a tableview for showing a list of devices in my application. When viewWillAppear is called, I add the self.searchDisplayController.searchBar as a subview to a headerView . I then assign self.tableView.tableHeaderView = headerView . It looks like this: I scroll the tableview down so that headerview goes out of view and then go to some other view controller by tapping on a cell. When I come back to this tableView, scroll up to the headerView, the searchBar becomes invisible, however on

How to keep scopebar even after pressed Cancel button?

蹲街弑〆低调 提交于 2019-12-17 20:26:38
问题 I have a UITableView with a searchbar on the top. I used UISearchDisplayController for implementing the same. And also it has a scope bar with two buttons. In default when I launch the app, the scope bar will be displayed. When I click the cancel button after the searching, the scopebar disappeared. So is there any way to keep the scopebar even after I pressed the Cancel button. I used the following code but its not working. - (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar {

UISearchBar animation issue

允我心安 提交于 2019-12-17 17:56:29
问题 I have a UIViewController in wich I want to show a tableview with the serchBar. As Simple as That: //viewDidLoad _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH(), SCREEN_HEIGHT()) style:UITableViewStylePlain]; _tableView.delegate = self; _tableView.dataSource = self; [self.view addSubview:_tableView]; // adding uisearch bar searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)]; _tableView.tableHeaderView = searchBar; //