I have this code, but I dont know how to show a textfield inside the UIAlertView.
var altMessage = UIAlertController(title: \"Warning\", message: \"This is A
Swift 4:
var textField: UITextField?
func configurationTextField(textField: UITextField!) {
if (textField) != nil {
self.textField = textField! //Save reference to the UITextField
self.textField?.placeholder = "Some text";
}
}
func openAlertView() {
let alert = UIAlertController(title: "Alert Title", message: "Alert Message", preferredStyle: UIAlertControllerStyle.alert)
alert.addTextField(configurationHandler: configurationTextField)
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler:nil))
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler:{ (UIAlertAction) in
print("User click Ok button")
}))
self.present(alert, animated: true, completion: nil)
}