I have a UIAlertView with a UITextField. I have connected the UIAlertView delegate and I return YES or NO in alertViewShouldEnableFirstOtherButton:
depending on the text in the UITextField.
I need to change the text of the textField programmatically. This works as expected.
Unfortunately I don't know how to make the UIAlertView call the alertViewShouldEnableFirstOtherButton:
delegate method so it enables or disables the other button after I changed the text of the textField.
I thought the UIAlertView registers as a target of UITextField, so I tried to send a UIControlEventValueChanged
from the textField. Didn't work.
From the stack trace I figured out the delegate method is called from the private UIAlertView method _alertSheetTextFieldDidChange:
.
So if I do [self.currentAlert performSelector:@selector(_alertSheetTextFieldDidChange:) withObject:textField];
after changing the text, the delegate method is called and the enable state of the button changes. But, since this is a private method, the app will probably be rejected. I don't want to risk that.
Is there a clean way to make the alert view call alertViewShouldEnableFirstOtherButton:
?
I was on the right track with sending a control event. I just choose the wrong event.
This will work:
[textField sendActionsForControlEvents:UIControlEventEditingChanged];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With