SCLAlertView-Swift icon indicating copy to clipboard operation
SCLAlertView-Swift copied to clipboard

Get text from the TextField

Open azaabudeen opened this issue 8 years ago • 2 comments

hello I used this method to create the button _ = alert.addButton("Submit", target:self, selector:#selector(ViewController.firstButton))

how will i reference the text inside the textfield in the firstButton method

azaabudeen avatar Oct 15 '17 17:10 azaabudeen

The addTextField method returns the UITextField instance you are interested in. Just save it as a property of your view controller and you can use it anywhere.

algrid avatar Feb 04 '18 21:02 algrid

Regards! this is an example that is in the readme.md

// Add a text field
let alert = SCLAlertView()
let txt = alert.addTextField("Enter your name")
alert.addButton("Show Name") {
    print("Text value: \(txt.text)")
}
alert.showEdit("Edit View", subTitle: "This alert view shows a text box")

elgartoinf avatar Aug 09 '18 16:08 elgartoinf