zmac

Pop-up con entrada de texto , Swift

CÓDIGO SWIFT PARA MOSTRAR UN POP-UP BOX CON ENTRADA DE TEXTO     

// pregunta
  let alert = UIAlertController(title: "What's your name?", message: nil, preferredStyle: .alert)
   
 // boton  
  alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
      
  alert.addTextField(configurationHandler: { textField in
            textField.placeholder = "Input your name here..."
        })
       
        alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
          
  // constante name
            if let name = alert.textFields?.first?.text {
                print("Your name: \(name)")
            }
        }))
       
        self.present(alert, animated: true)



fuente: https://learnappmaking.com/uialertcontroller-alerts-swift-how-to/