What's a simple way to get a text input popup dialog box on an iPhone

后端 未结 12 2104
-上瘾入骨i
-上瘾入骨i 2020-12-02 03:42

I want to get the user name. A simple text input dialog box. Any simple way to do this?

12条回答
  •  余生分开走
    2020-12-02 04:44

    Swift 3:

    let alert = UIAlertController(title: "Alert", message: "Message", preferredStyle: UIAlertControllerStyle.alert)
    alert.addAction(UIAlertAction(title: "Click", style: UIAlertActionStyle.default, handler: nil))
    alert.addTextField(configurationHandler: {(textField: UITextField!) in
         textField.placeholder = "Enter text:"
    })
    
    self.present(alert, animated: true, completion: nil)
    

提交回复
热议问题