Created
June 2, 2016 04:13
-
-
Save bauloc/a01a12fc42c5dc8b148c087bdc87c875 to your computer and use it in GitHub Desktop.
Alert View with Textfield.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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