iOS 7 Search Bar – Cancel button doesn’t work
我在 iOS 6 应用程序中有一个
我的代码是:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
– (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{ if (!SYSTEM_VERSION_LESS_THAN(@"7.0")) { [self filterContentForSearchText:searchString scope:nil]; } – (void) searchDisplayController:(UISearchDisplayController *)controller didShowSearchResultsTableView:(UITableView *)tableView { } |
感谢您的提前。
可能重复:UISearchBar 的取消和清除按钮在 iOS 7 中不起作用
编辑:
1
2 3 4 5 6 |
– (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{ self.searchDisplayController.searchBar.hidden = YES; self.tempImageView.hidden = NO; [searchBar resignFirstResponder]; } |
解决方案:
通过这个功能我解决了这个问题:
1
2 3 4 5 6 7 |
–(void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller { controller.active = YES; [self.view addSubview:controller.searchBar]; |
希望对你有帮助!
通过这个功能我解决了这个问题:
1
2 3 4 5 6 7 |
–(void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller { controller.active = YES; [self.view addSubview:controller.searchBar]; |
希望对你有帮助!
IOS 7 默认搜索栏将是透明的取消按钮
1
2 3 4 5 6 7 8 9 |
– (void)searchBarCancelButtonClicked:(UISearchBar *)aSearchBar
{ [aSearchBar resignFirstResponder]; isSearching = NO; aSearchBar.text = @""; [diaryTableView reloadData]; } |
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/268584.html