how to get input from UIAlertView?

[亡魂溺海] 提交于 2019-12-01 02:54:48

Yes, it's definitely possible, and it isn't a hack. You would need to subclass UIAlertView and place controls into it. Since it's a subclass, it will retain the same look & feel, etc.

For full details, see this tutorial by Jeff LaMarche (co-author of Beginning iPhone Development, from Apress).

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.

drewh

Yes, but not without some hacking, see this previous question. You'd have to directly manipulate the UIAlertView's subviews and add a UITextField and then resize the UIAlertView's frame. You're better off creating your own view.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!