http://iphonedevelopment.blogspot.com/2009/02/alert-view-with-prompt.html
I'm using that code to get my iPhone app to display an alertView with an included UITextField and matching CANCEL and OK buttons.
The user can enter text, hit CANCEL or OK... and I see the text the user entered... using my code inside the clickedButtonAtIndex method.
It all works except for 1 thing: Instead of OK, the user might hit DONE on the keyboard. I'm using dismissWithClickedButtonIndex to simulate an OK click... but then clickedButtonAtIndex never gets called.
Shouldn't dismissWithClickedButtonIndex also call clickedButtonAtIndex?
I'm trying to get clickedButtonAtIndex to get called if CANCEL, or OK, or even DONE is hit.
Since this is an old question you've probably figured it out by now, but I was incredibly frustrated with this and couldn't find any help from Google, so for anyone who comes across this in the future: when you call dismissWithClickedbuttonIndex
, the method that gets called is alertView:didDismissWithButtonIndex
, not alertView:clickedButtonAtIndex
. It behaves exactly the same way, and I can't figure out why they'd be two separate methods for what seems to be the same action, but there it is.
clickedButtonAtIndex
is called when user actually clicks the button. Clicking the button may or may not dismiss the alert. the standard OK/Cancel buttons have the effect of dismissing the alert on click. If a click translates to dismiss or a dismissWithClickedbuttonIndex
method is called, then did DismissWithButtonIndex
is called.
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