Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 944
Ketan Odedra Avatar asked Apr 21 '26 04:04

Ketan Odedra


1 Answers

the shouldReturn delegate method is what you are looking for:

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    // do something
    return YES;
}
like image 160
André Slotta Avatar answered Apr 22 '26 18:04

André Slotta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!