Questions tagged [uisearchbardelegate]

The UISearchBarDelegate protocol defines the optional methods you implement to make a UISearchBar control functional.

The UISearchBarDelegate protocol defines the optional methods you implement to make a UISearchBar control functional. On UISearchBarDelegate, you can find the following methods:

Editing Text

– searchBar:textDidChange:

– searchBar:shouldChangeTextInRange:replacementText:

– searchBarShouldBeginEditing:

– searchBarTextDidBeginEditing:

– searchBarShouldEndEditing:

– searchBarTextDidEndEditing:

Clicking Buttons

– searchBarBookmarkButtonClicked:

– searchBarCancelButtonClicked:

– searchBarSearchButtonClicked:

– searchBarResultsListButtonClicked:

Scope Button

– searchBar:selectedScopeButtonIndexDidChange:

150 questions
62
votes
11 answers

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

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 works perfectly fine with this code. override func touchesBegan(touches: NSSet, withEvent event:…
aji
  • 651
  • 1
  • 5
  • 10
45
votes
12 answers

UISearchbar clearButton forces the keyboard to appear

I have a UISearchBar which acts as a live filter for a table view. When the keyboard is dismissed via endEditing:, the query text and the gray circular "clear" button remain. From here, if I tap the gray "clear" button the keyboard reappears as the…
Jens Kohl
  • 5,899
  • 11
  • 48
  • 77
25
votes
10 answers

searchBarCancelButtonClicked delegate method is not called. Is there any way to call?

UIViewController to implement a view to placing an UITableView UISearchBar and being implemented. But you can not call searchBarCancelButtonClicked. Do not know what the reason.
Szakma
  • 251
  • 1
  • 3
  • 3
24
votes
1 answer

tvOS: Is there anyway to prevent the search keyboard from collapsing on scroll?

So I have a standard setup for setting up a search view in my tvOS app. let storyboard = UIStoryboard(name: "Main", bundle: nil) guard let resultsController =…
17
votes
2 answers

How do you hide/show UISearchBar's scope bar with animation?

I want to show no scope bar when the table is empty (before the search bar edits for the first time), no scope bar when it's editing, and finally show it when editing done. I know about the UISearchBarDelegate protocol, but I don't know how to…
zekel
  • 9,227
  • 10
  • 65
  • 96
14
votes
4 answers

UISearchBar delegate not responding to cancel button

I have a UIViewController that is a UISearchBarDelegate and a MKMapViewDelegate. The searchBarSearchButtonClicked event works fine, but when testing in iOS 4.2 the searchBarCancelButtonClicked never gets called when hitting the cancel button. In 4.3…
user213517
  • 511
  • 2
  • 5
  • 6
14
votes
1 answer

Detect when user stopped / paused typing in Swift

I've dug around stackoverflow and found the solution which I converted to Swift, it doesn't seem to work and the selector is still being performed. func searchBar(searchBar: UISearchBar, textDidChange searchText: String) { …
Tuan Anh Vu
  • 760
  • 1
  • 7
  • 26
11
votes
5 answers

How to make UITextField behave like a UISearchBar in Swift?

I am working on an new App using UITableView and a UISearchBar in Swift and it's already working fine. But since the final project must have a complete customized searchbar, I had to move to UITextField as the input Outlet because of the…
Marco Almeida
  • 1,285
  • 3
  • 17
  • 39
10
votes
7 answers

How can I disable/enable UISearchBar keyboard's Search button?

I am using UISearchBar in my code. I have imported its delegate in header file and implemented some delegate methods in implementation file also. When we tap on the UISearchBar, a keyboard will appear to enter text. The return key of the keyboard is…
Confused
  • 3,846
  • 7
  • 45
  • 72
9
votes
4 answers

UISearchBar and event fired when 'X' element is tapped

On the UISearchBar, there's an X element that allows you to clear all of the contents at once. Is there a way to get notified when this happens? UISearchBarDelegate::searchBarCancelButtonClicked is fired only when the "Cancel" button is tapped.
Justin Galzic
  • 3,951
  • 6
  • 28
  • 39
8
votes
1 answer

Is it not possible to put UISearchBar in UITableView header?

I am trying to accomplish this: Consider a table view with Search Bar on its header.Table view gets refreshed whenever string is searched. I am having 2 classes TableViewController(UIViewController subclass) contains UITableView -That shows…
prajul
  • 1,216
  • 2
  • 15
  • 27
7
votes
2 answers

resign keyboard when losing focus on uisearchbar

I'm making an UISearchBar option in the navigationbar of my app. My app consists of multiple views and subviews. I have this mainview which has 3 other views on himself. one of it is empty (for now) the other 2 have tableviews on them. I want my…
6
votes
3 answers

UISearch bar not calling searchBarTextDidBeginEditing

I have a simple view controller with a uisearchbar and a uitable. My problem is that when search bar is tapped I see delegate function searchBarShouldBeginEditing being called but not searchBarTextDidBeginEditing(and because of that keyboard is not…
M Penades
  • 1,572
  • 13
  • 24
6
votes
2 answers

How to assign searchBar of storyboard to searchController's searchBar property

When I add my searchBar as a headerView of tableView, all the delegate methods are fired as expected. self.myTableView.tableHeaderView = self.searchController.searchBar; But if I take a searchBar IBOutlet from StoryBoard and assign it to…
Viki
  • 421
  • 1
  • 4
  • 12
6
votes
2 answers

Double tap UISearchBar with search delegate on iOS 7 causes UISearchBar to disappear

We have a search bar in the table header. When the user taps on it twice quickly on iOS 7, it disappears. Does anyone have any suggestions what we are doing wrong?
1
2 3
9 10