how to get input from UIAlertView?

后端 未结 3 953
孤独总比滥情好
孤独总比滥情好 2021-01-11 13:27

I want take player name as input by using UIAlertView. Is it possible to add textField on the UIAlertView?

3条回答
  •  盖世英雄少女心
    2021-01-11 14:17

    Since iOS 5, UIAlertView provides this: change the alertViewStyle property to one of the following:

    UIAlertViewStylePlainTextInput (1 text field)
    UIAlertViewStyleSecureTextInput (1 password field)
    UIAlertViewStyleLoginAndPasswordInput (both a text field and password field)
    

    Then use textFieldAtIndex: to get the text field you want. This way, you can even use the alertViewShouldEnableFirstOtherButton: delegate method to enable the button.

提交回复
热议问题