私はtextfield
とを持っていtableview
ます。ユーザーは、またはその他のtextfield
データからデータを選択できます。しかし、ユーザー自身のデータを入力した後、私は消える必要があります。これを達成するにはどうすればよいですか。tableview
tableview
did select row
tableview
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
txtcity.text = selectedCell.textLabel.text;
}
-(void)hideKeyboard //this is my gesture recogniser method
{
autocompletetableview.hidden=true;//if i didn't use this statement it enter into didselectrow method
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
autocompleteTableView.hidden=YES;
if( textField == txtcity)
{
autocompleteTableView.hidden = NO;
NSString *substring = [NSString stringWithString:textField.text];
substring = [substring stringByReplacingCharactersInRange:range withString:string];
[self searchAutocompleteEntriesWithSubstring:substring];// this method loads data into my tableview
return YES;
}
}
(BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
if([txtcity.text isEqualToString:@""])
{
autocompleteTableView.hidden=YES;
return YES;
}
else
autocompleteTableView.hidden=NO;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section {
return arr2.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = nil;
static NSString *AutoCompleteRowIdentifier = @"AutoCompleteRowIdentifier";
cell = [tableView dequeueReusableCellWithIdentifier:AutoCompleteRowIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault reuseIdentifier:AutoCompleteRowIdentifier] autorelease];
}
cell.textLabel.text = [[arr2 objectAtIndex:indexPath.row]objectForKey:@"Name"];
cell.textLabel.font=[UIFont boldSystemFontOfSize:12];
cell.textLabel.numberOfLines=0;
return cell;
}
このように使用すると、行を選択すると、インデックスパスメソッドで行を選択しません。助けて
私はresignfirstresponderを使用しなければならない場所に行きません