Skip to content

Instantly share code, notes, and snippets.

@bauloc
Created June 2, 2016 04:13
Show Gist options
  • Save bauloc/a01a12fc42c5dc8b148c087bdc87c875 to your computer and use it in GitHub Desktop.
Save bauloc/a01a12fc42c5dc8b148c087bdc87c875 to your computer and use it in GitHub Desktop.
Alert View with Textfield.swift
//1. Create the alert controller.
var alert = UIAlertController(title: "Report", message: "Nhập nội dung", preferredStyle: .Alert)
//2. Add the text field. You can configure it however you need.
alert.addTextFieldWithConfigurationHandler({ (textField) -> Void in
textField.text = ""
// textField.placeholder = "Nhập nội dung..."
})
//3. Grab the value from the text field, and print it when the user clicks OK.
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: { (action) -> Void in
let textField = alert.textFields![0] as UITextField
// println("Text field: \(textField.text)")
}))
// 4. Present the alert.
FPTPlayDelegate.window?.rootViewController!.presentViewController(alert, animated: true, completion: nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment