美文网首页
(IOS)自动搜索功能,用户连续输入的时候不搜索,用户停止输入的

(IOS)自动搜索功能,用户连续输入的时候不搜索,用户停止输入的

作者: rightmost | 来源:发表于2018-08-10 17:34 被阅读0次

 // 输入框文字改变的时候调用

    -(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{

        // 先取消调用搜索方法

        [NSObject cancelPreviousPerformRequestsWithTarget:selfselector:@selector(searchNewResult) object:nil];

        // 0.5秒后调用搜索方法

        [selfperformSelector:@selector(searchNewResult) withObject:nilafterDelay:0.5];

    }

相关文章

网友评论

      本文标题:(IOS)自动搜索功能,用户连续输入的时候不搜索,用户停止输入的

      本文链接:https://www.haomeiwen.com/subject/atslbftx.html