iOS UITextField/UISearchBar的clearButton的响应事件

- (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

原文地址:https://www.cnblogs.com/qingzZ/p/15405571.html