开发者

SearchBar text empty when searchBarSearchButtonClicked called

开发者 https://www.devze.com 2023-03-19 13:45 出处:网络
I\'ve implemented the searchBarSearchButtonClicked delegate method in my view controller 开发者_C百科- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号