为什么在警报视图文本字段中未启用自动更正? (以及如何启用它?)

时间:2015-01-18 12:07:30

标签: ios swift

我正在创建一个警报视图:

var alert = UIAlertController(title: "Place the pin", message: "Aditional details", preferredStyle: .Alert)
let saveAction = UIAlertAction(title: "Ajouter", style: .Default) {
(_:UIAlertAction!) -> Void in 

 }

let cancelAction = UIAlertAction(title: « Cancel », style: .Default) {
                    (_:UIAlertAction!) -> Void in
}

alert.addTextFieldWithConfigurationHandler() { (_:UITextField!) -> Void in }
alert.addAction(cancelAction)
alert.addAction(saveAction)

presentViewController(alert, animated: true, completion: nil)

但我不明白为什么在警报的文本字段中未启用自动更正?我该如何启用它? 谢谢。

1 个答案:

答案 0 :(得分:1)

实际上我必须明确指定它,所以我更换了:

alert.addTextFieldWithConfigurationHandler() { (_:UITextField!) -> Void in }

使用:

alert.addTextFieldWithConfigurationHandler() { (textField:UITextField!) -> Void in  textField.autocorrectionType = UITextAutocorrectionType.Yes }