I am trying to show a UIAlertController
with a UITextView
. When I add the line:
//Add text field
alertController.addTextFie
Great answer a slight modification to show how the textfield can be used:
func addRow (row: Int, bodin: String, flag: Int) {
let alertController = UIAlertController(title: bodin, message: "", preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "Save", style: .default, handler: {
alert -> Void in
_ = alertController.textFields![0] as UITextField
}))
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
alertController.addTextField(configurationHandler: {(textField : UITextField!) -> Void in
switch flag {
case 0:
textField.keyboardType = UIKeyboardType.phonePad
textField.placeholder = "Enter Number"
case 1:
textField.keyboardType = UIKeyboardType.emailAddress
textField.placeholder = "Enter Email"
default:
break
}
})