Wednesday, 8 January 2014

AlertView Text Field


UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"Subscribe to Newsletter" message:@"Please Enter Your Email id:" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Submit", nil];
        av.alertViewStyle = UIAlertViewStylePlainTextInput;
        [av textFieldAtIndex:0].delegate = self;
        [av show];


- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{
    
    // The first button (or cancel button)
    if (buttonIndex == 0) {
    }
    
    // The second button on the alert view
    if (buttonIndex == 1) {
        NSLog(@"Alert-%@",[av textFieldAtIndex:0].text);
}
}

No comments:

Post a Comment