ios - How to set default text for addTextField in UIAlertController in Swift -
below the code tried. textfield.placeholder works perfectly, need set default text textfield created using addtextfield in uialertcontroller.
let getpinnamealert = uialertcontroller(title: title, message: message, preferredstyle: .alert) getpinnamealert.addtextfield(configurationhandler: { (textfield) -> void in // textfield.placeholder = "pin name" textfield.text = "current pin name" textfield.keyboardtype = uikeyboardtype.default textfield.clearsonbeginediting = true })
remove line textfield.clearsonbeginediting = true
by default, alert automatically focuses on text field, why text set being cleared.
Comments
Post a Comment