开发者

How do you get the text the user entered into the search Bar?

开发者 https://www.devze.com 2023-03-13 02:36 出处:网络
I want to be able to get the text the user entered into a search bar, and compare the words i开发者_如何学JAVAn an array.But i\'m not sure how to get the text from the search bar, I know in java its j

I want to be able to get the text the user entered into a search bar, and compare the words i开发者_如何学JAVAn an array. But i'm not sure how to get the text from the search bar, I know in java its just getText.


Assuming you named the UISearchBar just searchBar, you can retrieve the text with

searchBar.text


In SearchBar Delegate method, you can get searchbar text

-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
    NSString *str = searchBar.text;
    NSLog(@"%@",str);
}
0

精彩评论

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

关注公众号