How to dismiss an UIAlertController and the keyboard simultaneously?

后端 未结 8 1340
离开以前
离开以前 2021-02-05 13:04

I have created a signup form with a UIAlertController and used the method addTextFieldWithConfigurationHandler to add a text field. But there is a litt

8条回答
  •  轮回少年
    2021-02-05 13:22

    no need to do any thing you just have to implement this much of code, it works for me, no need to declare any kind of delegate methods

    - (void)showAlert {
    self.alertController = [UIAlertController alertControllerWithTitle:@"Alert"
                                                               message:@"Enter Name:"
                                                        preferredStyle:UIAlertControllerStyleAlert];
    [self.alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
    
    }];
    [self.alertController addAction:[UIAlertAction actionWithTitle:@"Ok"
                                                             style:UIAlertActionStyleCancel
                                                           handler:nil]];
    [self presentViewController:self.alertController animated:YES completion:nil];
    

    }

提交回复
热议问题