AlertController with textfield

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@”Enter Referance”

                                                                       message:nil

                                                                preferredStyle:UIAlertControllerStyleAlert];

        [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {

            // optionally configure the text field

            textField.keyboardType = UIKeyboardTypeDefault;

        }];

        

        UIAlertAction *okAction = [UIAlertAction actionWithTitle:@”OK”

                                                           style:UIAlertActionStyleDefault

                                                         handler:^(UIAlertAction *action) {

                                                             UITextField *textFieldEnterOtherReferance = [alertController.textFields firstObject];

                                                             NSLog(@”%@”,textFieldEnterOtherReferance.text);

                                                             if ([Utility trimString_RemoveWhiteSpaceFromString:textFieldEnterOtherReferance.text].length != 0)

                                                             {

                                                                 _labelReferance.text = textFieldEnterOtherReferance.text;

                                                             }

                                                             _viewPopUpBelowTable.hidden = YES;

                                                             _tableViewPopUp.hidden = YES;

                                                         }];

        [alertController addAction:okAction];

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

Leave a comment