Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

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)
Comment

PREVIOUS NEXT
Code Example
Swift :: get length of array swift 
Swift :: swiftui color picker 
Swift :: find object in array by property swift 
Swift :: print document directory path swift 
Swift :: how to remove background color for uibutton swift 
Swift :: xcode hide keyboard when touch background storyboard 
Swift :: swift scrollview hide scrollbar 
Swift :: swift compare string to button title 
Swift :: date in swiftui 
Swift :: check when webview finish loading swift 
Swift :: swiftui pintch to zoom 
Swift :: swift get day from available string 
Swift :: Fetch structure from userdefaults ios swift 
Swift :: blur background swiftUI 
Swift :: swiftui steppers 
Swift :: get keyboard height swift 
Swift :: and in swift6 
Swift :: uitableview set space between cells 
Swift :: closure swift 
Swift :: swift contains 
Swift :: swift make condition that you are in sumulator 
Swift :: how to set the font of text in swiftui 
Swift :: swift constructor 
Swift :: swiftui tutorial 
Swift :: debounce in swift 
Swift :: swift add enum storyboard 
Swift :: Swift Half-Open Range 
Swift :: Swift Add/Remove Elements From Tuple 
Swift :: how to multiply numbers in array swift 
Swift :: Swift Nested Ternary Operators 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =