Skip to content

Instantly share code, notes, and snippets.

@tonisuter
Created September 20, 2017 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonisuter/7c1648e1920f57a20fd57d5c7b646270 to your computer and use it in GitHub Desktop.
Save tonisuter/7c1648e1920f57a20fd57d5c7b646270 to your computer and use it in GitHub Desktop.
UIAlertController Example
@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