show alert with textfield swift
//1. Create the alert controller.
let alert = UIAlertController(title: "Some Title", message: "Enter a text", preferredStyle: .alert)
//2. Add the text field. You can configure it however you need.
alert.addTextField { (textField) in
textField.text = "Some default text"
}
// 3. Grab the value from the text field, and print it when the user clicks OK.
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { [weak alert] (_) in
let textField = alert.textFields![0] // Force unwrapping because we know it exists.
print("Text field: \(textField.text)")
}))
// 4. Present the alert.
self.present(alert, animated: true, completion: nil)
Also in Swift:
- how to get appdelegate object in swift
- swift share with
- Module compiled with Swift 5.3 cannot be imported by the Swift 5.3.1 compiler
- get tabbar height swift
- how do change title color in navigation bar
- uilabel.text from array string
- How to find index of list item in Swift?
- swift VStack
- check enumatted arrray last item swift
- swift thread.sleep
- disable swipe to delete swift
- remove all add TapGestureRecognizer swift
- swift empty an array
- swift resource exceeds maximum size
- swift assign tuple to variables
- swift function in a variable
- change ui button swift
- string to decimal swift
- list header swiftui
- create alert in swift
- swift textfield trim special characters before database
- swift filter array
- save date to userdefaults swift
- navigationBarTitle text size swiftui