Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • UIAlertViewController with TextFiled in iOS

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 515
    Comment on it

    To Create a alertView with textField in Xcode 7.2 we can Use the the code below to handle the Yes and no action.

    and also get the text of the textField. You can show this on a viewController.

     

    UIAlertController * alert=   [UIAlertController
                                      alertControllerWithTitle:@"Set title Here"
                                      message:@"set Message Here"
                                      preferredStyle:UIAlertControllerStyleAlert];
        
        [alert addTextFieldWithConfigurationHandler:^(UITextField *textField)
         {
    
    textField.placeholder = @"placeholdertext";
    
    
         }];
    
        
        UIAlertAction* yesButton = [UIAlertAction
                                    actionWithTitle:@"Yes"
                                    style:UIAlertActionStyleDefault
                                    handler:^(UIAlertAction * action)
                                    {
                                        
                                        UITextField *myTextFiled = alert.textFields.firstObject;
                                        NSLog(@"Text of the fiedld== %@",myTextFiled.text);
                                       
    
                                        
                                        
                                    }];
        UIAlertAction* noButton = [UIAlertAction
                                   actionWithTitle:@"No"
                                   style:UIAlertActionStyleDefault
                                   handler:^(UIAlertAction * action)
                                   {
                                       //Handel no, button
                                       
                                   }];
        
        [alert addAction:yesButton];
        [alert addAction:noButton];
        
        [self presentViewController:alert animated:YES completion:nil];

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: