¿Cómo descartar un UIAlertController y el teclado simultáneamente?

He creado un formulario de registro con unUIAlertController y usé el métodoaddTextFieldWithConfigurationHandler para agregar un campo de texto. Pero hay un pequeño problema.

Cuando aparece el formulario, el teclado y el modal aparecen con una animación suave. Al cerrar el formulario, el modal desapareceprimeroyentonces El teclado desaparece. Esto hace que el teclado caiga repentinamente hacia abajo.

¿Cómo puedo hacer que el modal y el teclado desaparezcan graciosamente?

lazy var alertController: UIAlertController = { [weak self] in
    let alert = UIAlertController(title: "Alert", message: "This is a demo alert", preferredStyle: .Alert)
    alert.addTextFieldWithConfigurationHandler { textField in
        textField.delegate = self
    }
    alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
    return alert
}()

@IBAction func alert() {
    presentViewController(alertController, animated: true, completion: nil)
}

func textFieldShouldReturn(textField: UITextField) -> Bool {
    alertController.dismissViewControllerAnimated(true, completion: nil)
    return true
}

Respuestas a la pregunta(8)

Su respuesta a la pregunta