Tuesday, June 16, 2015

UIAlertController * alert=   [UIAlertController alertControllerWithTitle:@"Text" message:@"Enter Text" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
                                               handler:^(UIAlertAction * action) {
                                                   //Do Some action here
                                                   UITextField *textField = alert.textFields.firstObject;
                                                   NSLog(@"%@",textField.text);
                                               }];
    UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault
                                                   handler:^(UIAlertAction * action) {
                                                       [alert dismissViewControllerAnimated:YES completion:nil];
                                                   }];
    
    [alert addAction:ok];
    [alert addAction:cancel];
    
    [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
                        textField.placeholder = @"Enter text here";
    }];
    

    [self presentViewController:alert animated:YES completion:nil];

No comments:

Post a Comment