Get In Touch
This form does not yet contain any fields.

    Main | Simple ARC explanation »

    Text Input in UIAlertViews


    iOS developers have been hacking away at trying to find a good solution for presenting users with a text input on a popup.  Some developers have been successful at getting this to work, but it has never been a pretty or simple solution. iOS 5 provides several simple solutions to this problem with the new UIAlertViewStyles that are now available.

    UIAlertViewStylePlainTextInput is the most simplistic of the new styles and presents a standard UIAlertView with an embeded UITextField.  In order to receive the text input into this UITextField, you must implement the UIAlertViewDelegate method didDismissWithButtonIndex.  A simple example implementation...

    UIAlertViewStyleLoginAndPasswordInput works exactly the same except you receive two text fields for input, the username and password.  Again you can get these contents form the UIAlertViewDelegate method didDismissWithButtonIndex, with the login field having a index of 0 and the password field having an index of 1.

    References (5)

    References allow you to track sources for this article, as well as articles that were written in response to this article.

    Reader Comments (2)

    Awesome post, I'm the owner of - would you be interested in writing for us? - We have around 20,000+ impressions so its great for exposure.

    January 22, 2012 | Unregistered CommenterMark Petherbridge

    Nice pieces of code. Are they still applicable?

    July 13, 2012 | Unregistered Commentervisit our site

    PostPost a New Comment

    Enter your information below to add a new comment.

    My response is on my own website »
    Author Email (optional):
    Author URL (optional):
    Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>