开发者

prevent search button from clearing search bar text

开发者 https://www.devze.com 2023-02-19 13:54 出处:网络
After clicking \"search\" on the keyboard, the search bar text clears.Is there a way to keep the text in the search bar? Why would it disappear?

After clicking "search" on the keyboard, the search bar text clears. Is there a way to keep the text in the search bar? Why would it disappear?

Note: I'm using the se开发者_高级运维arch display controller to activate and deactive the search


I found this from a somewhat related question... but the following code should keep the search term visible when the user clicks the search button.

-(void) searchBarSearchButtonClicked:(UISearchBar *)searchBar {
    NSString *str = searchBar.text;
    [self.searchController setActive:NO animated:YES];
    self.searchController.searchBar.text = str;
}
0

精彩评论

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