iOS实时搜索策略
[self.textFiled bk_addEventHandler:^(UITextField *sender) {
[selfWeak realTimeSearch];
} forControlEvents:UIControlEventEditingChanged];
- (void)realTimeSearch{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(searchModelByText:) object:self.searchTextFiled.textFiled];
[self performSelector:@selector(searchModelByText:) withObject:self.searchTextFiled.textFiled afterDelay:0.6];
}
- (void)searchModelByText:(UITextField *)textfile{
NSString *text = textfile.text;
if ([NSString isBlankString:text]) return;
// 自己的逻辑
}
本文标题:iOS实时搜索策略
本文链接:https://www.haomeiwen.com/subject/hddwaqtx.html
网友评论