简体   繁体   中英

Click button to amend textfield, textFieldDidEndEditing not called?

So i've got a couple of checks going on within textFieldDidEndEditing which basically enable or disable the input of a text box, they seem to be working fine.

When I have an IBAction associated with a button that affects the values inside of a text box, does textFieldDidEndEditing not get called? It seems to only respond when i'm actually within a textBox typing.

I have this method which resets my text boxes and I want to run textFieldDidEndEditing after it but don't know how to pass a generic textField to it as the sender of the reset method isnt a text field.

- (IBAction)reset;
{
    txtCost.text = @"";
    txtPrice.text = @"";
    txtProfit.text = @"";
    txtMargin.text = @"";
    txtMarkup.text = @"";
    txtTaxPercentage.text = @"";
    txtTaxAmount.text = @"";



} 

Thanks, any clarification or help would be great.

The delegate method textFieldDidEndEditing will not be called if you are manually changing the text inside of a textField using another sender. That delegate method responds to resignFirstResponder so it will never be fired in your case.

What you can do is manually call it though based on the textField you want.

[self textFieldDidEndEditing:_yourTextField];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM