I've implemented the searchBarSearchButtonClicked delegate method in my view controller
开发者_C百科- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
searchBar.text = textView.text
}
The method is successfully called when the "Search" button is clicked but the searchBar.text property is empty.
Any ideas why searchBar.text would be empty?
You should use the value from "searchBar.text" instead of assigning the value of the "textView.text" to it. Try this:
Comment this "searchBar.text = textView.text" and add "NSLog(@"%@",searchBar.text);"
Check in your log the value of the search bar now. You could also check your XIB file, if you have connected your search bar's delegate to your File's owner.
精彩评论