|
@@ -21,14 +21,14 @@
|
|
|
// [self.active_field endEditing:true];
|
|
// [self.active_field endEditing:true];
|
|
|
// self.hidden = true;
|
|
// self.hidden = true;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+// self.searchInput.text = nil;
|
|
|
[self.searchInput endEditing:true];
|
|
[self.searchInput endEditing:true];
|
|
|
- self.searchInput.text = nil;
|
|
|
|
|
|
|
+
|
|
|
self.arr_result = nil;
|
|
self.arr_result = nil;
|
|
|
self.hidden=true;
|
|
self.hidden=true;
|
|
|
[self.ResultTableView reloadData];
|
|
[self.ResultTableView reloadData];
|
|
|
}
|
|
}
|
|
|
-#pragma mark - SearchBar Delegate
|
|
|
|
|
|
|
+#pragma mark - TextField Delegate
|
|
|
|
|
|
|
|
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
|
|
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
|
|
|
// autocompleteTableView.hidden = NO;
|
|
// autocompleteTableView.hidden = NO;
|
|
@@ -53,6 +53,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)textFieldDidEndEditing:(UITextField *)textField
|
|
|
|
|
+{
|
|
|
|
|
+ if(self.returnValue)
|
|
|
|
|
+ self.returnValue(textField.text);
|
|
|
|
|
+ textField.text = nil;
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
//- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField; // return NO to disallow editing.
|
|
//- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField; // return NO to disallow editing.
|
|
|
//- (void)textFieldDidBeginEditing:(UITextField *)textField; // became first responder
|
|
//- (void)textFieldDidBeginEditing:(UITextField *)textField; // became first responder
|
|
@@ -75,13 +83,20 @@
|
|
|
[self.ResultTableView reloadData];
|
|
[self.ResultTableView reloadData];
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ __weak typeof(self) weakself = self;
|
|
|
if(self.dataSource)
|
|
if(self.dataSource)
|
|
|
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
-
|
|
|
|
|
- self.arr_result = [self.dataSource sync_loadCadidate:keyword];
|
|
|
|
|
|
|
+ NSString* searchid=[[NSUUID new] UUIDString];
|
|
|
|
|
+ weakself.lastSearchID=searchid;
|
|
|
|
|
+ NSArray* arr_ret=[weakself.dataSource sync_loadCadidate:keyword ];
|
|
|
|
|
+// NSArray* arr_ret=[weakself.dataSource sync_loadCadidate:keyword search_id:weakself.lastSearchID];
|
|
|
|
|
+// self.arr_result = [self.dataSource sync_loadCadidate:keyword search_id:[[NSUUID new] UUIDString]];
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- [self.ResultTableView reloadData];
|
|
|
|
|
|
|
+ if([searchid isEqualToString:weakself.lastSearchID])
|
|
|
|
|
+ {
|
|
|
|
|
+ self.arr_result = arr_ret;
|
|
|
|
|
+ [self.ResultTableView reloadData];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
});
|
|
@@ -130,10 +145,12 @@
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
|
|
|
|
|
|
|
|
- if(self.returnValue)
|
|
|
|
|
- self.returnValue(self.arr_result[indexPath.row][@"value"]);
|
|
|
|
|
|
|
+// if(self.returnValue)
|
|
|
|
|
+// self.returnValue(self.arr_result[indexPath.row][@"value"]);
|
|
|
|
|
+
|
|
|
|
|
+ self.searchInput.text = self.arr_result[indexPath.row][@"value"];
|
|
|
[self.searchInput endEditing:true];
|
|
[self.searchInput endEditing:true];
|
|
|
- self.searchInput.text = nil;
|
|
|
|
|
|
|
+// self.searchInput.text = nil;
|
|
|
self.arr_result = nil;
|
|
self.arr_result = nil;
|
|
|
self.hidden=true;
|
|
self.hidden=true;
|
|
|
[self.ResultTableView reloadData];
|
|
[self.ResultTableView reloadData];
|