My Blog List

Android FirstAid Coding

A Small Help From a Small Heart
Powered by Blogger.

A software professional, who still likes to code, likes to blog and loves gadgets.

Friday 12 July 2013

How to show multiple UITextField within UIalertView ios

Create alertview to show

UIAlertView *dialog = [[UIAlertView alloc] initWithTitle:@"Please enter" message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];

    [dialog setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];   
    [[dialog textFieldAtIndex:1] setSecureTextEntry:NO];
    [[dialog textFieldAtIndex:0] setPlaceholder:@"User Name"];
    [[dialog textFieldAtIndex:1] setPlaceholder:@"Email Id"];
    [dialog show];


This is the delegate method to catch the user input

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{    
         [alertView dismissWithClickedButtonIndex:0 animated:YES];
        if (buttonIndex == 0) {
           //cancel clicked
        }else {
                     
            NSString *name = [[alertView textFieldAtIndex:0].text stringByTrimmingCharactersInSet:
                    [NSCharacterSet whitespaceCharacterSet]];   
            NSString *email = [[alertView textFieldAtIndex:1].text stringByTrimmingCharactersInSet:
                     [NSCharacterSet whitespaceCharacterSet]];
           
        }      

}


2 comments:

  1. Very informative post.I am really impressed by this incredible precious site .Nice blog! I loved reading through your blog.
    wish you good luck for your best efforts...

    iPhone App Development :: && :: Mobile and Web Application Development

    ReplyDelete
  2. Smith, Please, accept my heartfelt thanks, for your invaluable moral support. This will surely become driving force for me...

    Thanks Again

    ReplyDelete