У меня есть следующий код, который использует предупреждение для получения адреса электронной почты от пользователя. Я хотел бы указать тип клавиатуры, но не смог понять, как это сделать в предупреждении. Кто-нибудь может помочь показать, как установить .keyboardType = UIKeyboardType.emailAddress
?
var userInput: String = ""
let prompt = UIAlertController.init(title: nil, message: "Enter your email address", preferredStyle: UIAlertControllerStyle.alert)
let okAction = UIAlertAction.init(title: "OK", style: UIAlertActionStyle.default) { (action) in
userInput = prompt.textFields![0].text
if (userInput!.isEmpty) {
return
}
}
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (action) in
print(action)
}
prompt.addTextField(configurationHandler: nil)
prompt.addAction(okAction)
prompt.addAction(cancelAction)
self.view?.window?.rootViewController?.present(prompt, animated: true, completion: nil)