- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { if (searchText.length == 0) { [self performSelector:@selector(hideKeyboaedWithSearchBar:) withObject:searchBar afterDelay:0]; } } ///监听点击清空空按钮 - (void)hideKeyboaedWithSearchBar:(UISearchBar *)bar{ NSLog(@"点击了清空X "); [StatisticsTool buriedPoint:3597 withOther:@{@"s0":@"0"}]; }
参考:https://juejin.cn/post/6844903824478437383