Check this out:
let alertController = UIAlertController(title: "Email?", message: "Please input your email:", preferredStyle: .Alert)
let confirmAction = UIAlertAction(title: "Confirm", style: .Default) { (_) in
if let field = alertController.textFields![0] as? UITextField {
// store your data
NSUserDefaults.standardUserDefaults().setObject(field.text, forKey: "userEmail")
NSUserDefaults.standardUserDefaults().synchronize()
} else {
// user did not fill field
}
}
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (_) in }
alertController.addTextFieldWithConfigurationHandler { (textField) in
textField.placeholder = "Email"
}
alertController.addAction(confirmAction)
alertController.addAction(cancelAction)
self.presentViewController(alertController, animated: true, completion: nil)
fonte
2015-04-22 20:54:25
Si prega di dare qualche dettaglio su ciò che avete già provato, e che cosa in particolare ti ellude. Questo non è un posto appropriato per iniziare la tua ricerca. Prova prima [Google] (http://www.google.com). Vieni qui quando hai fatto qualche ricerca e vuoi aiuto con un punto specifico. –