How to add a TextField to UIAlertView in Swift

前端 未结 10 1098
耶瑟儿~
耶瑟儿~ 2020-12-23 13:41

I have this code, but I dont know how to show a textfield inside the UIAlertView.

var altMessage = UIAlertController(title: \"Warning\", message: \"This is A         


        
10条回答
  •  不知归路
    2020-12-23 14:31

    You can access the textfield with:

    let textField = alert.textFieldAtIndex(0)
    

    Then to change the placeholder text:

    textField.placeholder = "Foo!"
    

    And the keyboard type:

    textField.keyboardType = ...
    

提交回复
热议问题