开发者

SearchBar text empty when searchBarSearchButtonClicked called

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜