iosobjective-cuitableviewuitextfield

UITextField method call when done button click


I have a textfield in a UITableViewCell

When I clicked in textfield directly this method is called:

-(void)editingChanged:(UITextField *)sender

this is my code in cellForRowAtIndexPath

[cell.ProductQuantityTextField addTarget:self action:@selector(editingChanged:)forControlEvents:UIControlEventEditingChanged];


-(void) editingChanged:(UITextField *)sender
{
    NSLog( @"text changed: %@",cell.ProductQuantityTextField.text);
    [self ProdcutDirectSetToCartAPICall];
}

I want that, when I click the textfield then I change the value of textfield and then I click done button of keyboard that time I want call UITextField method


Solution

  • You can check UItextfield's shouldreturn method call

    - (BOOL)textFieldShouldReturn:(UITextField *)textField {
        NSLog( @"text changed: %@",textField.text);
        [self ProdcutDirectSetToCartAPICall];
        return YES;
    }