UIAlertController's textfield delegate does not get called

The text field that you're setting the delegate for is not the same text field that is added to the alert controller. Basically, you're creating a new instance of UITextField, but never giving it a frame, or adding it to the view hierarchy. At the same time, you're using addTextFieldWithConfigurationHandler() to add a text field to the alert controller, but you never set the delegate for this text field. I believe this is what you want:

let alertController = UIAlertController(title: "", message: "xxx", preferredStyle: .Alert)

alertController.addTextFieldWithConfigurationHandler {[weak self] (textField: UITextField!) in
    textField.delegate = self
}

self.presentViewController(alertController, animated:true, completion:nil)