Created
September 20, 2017 08:07
-
-
Save tonisuter/7c1648e1920f57a20fd57d5c7b646270 to your computer and use it in GitHub Desktop.
UIAlertController Example
This file contains hidden or 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
@IBAction func logSolution(sender: UIBarButtonItem) { | |
let alertController = UIAlertController(title: "Log Solution", | |
message: "Please enter your solution.", | |
preferredStyle: .alert) | |
alertController.addTextField(configurationHandler: { textField in | |
textField.autocorrectionType = .no | |
}) | |
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel)) | |
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in | |
guard let solution = alertController.textFields?[0].text else { | |
return | |
} | |
// In der Konstante solution steht das Lösungswort, das vom Benutzer eingegeben wurde. | |
// TODO: Dieses Wort muss jetzt ähnlich wie beim Metalldetektor im Logbuch eingetragen werden. | |
})) | |
present(alertController, animated: true) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment