SearchBar textDidChange

In my TableViewController using searchBar, I use the following method:

-(void) searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText 
{
   ...my code
}

and it works great when entering text directly into the searchBar.

Now the problem is that I want to call this method programmatically - this means that I want to fill in the search string from my code, which I know how to do (in fact, I select the recently found word in my application language dictionary) and call something like:

 [SearchBar textDidChange: recentlySearchedWord]

but it just doesn't work anywhere in my code.

Please help me if you have an idea how to solve this problem.

Thank,

Tim

+5
source share
3 answers

UISearchBar - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText ( ), , , ,

[self searchBar:SearchBar textDidChange:recentlySearchedWord];

SearchBar UISearchBar, .

+7

textDidChange . :

[SearchBar textDidChange: recentlySearchedWord];

[self searchBar:mySearchBar textDidChange: recentlySearchedWord];

, textDidChange , insted self.

+1

You can also try using this code if it makes things easier.

<!DOCTYPE html>
<html>
<head>
<style>
input[type=text] {
    width: 100%;
    box-sizing: border-box;
    border: 2px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    background-color: white;
    background-image: url('searchicon.png');
    background-position: 10px 10px;
    background-repeat: no-repeat;
    padding: 12px 20px 12px 40px;
}
</style>
</head>
<body>

<p>Input with icon:</p>

<form>
  <input type="text" name="search" placeholder="Search..">
</form>

</body>
</html>
Run codeHide result
-1
source

All Articles