Methods for obtaining user input on iPhone
I'm workin开发者_运维百科g on an iPhone app and would like to have a simple text input box pop up when a user clicks my custom search button. My problem is that I'm not sure what approaches are available for achieving this. Googling results in search overload and I am presented with so many views that I'm not sure what is standard and what isn't. The information I am requesting from the user is a single zip code so I would like to avoid creating a whole new view for this if possible. I am still new to working in Xcode so please take it easy on me.
Edit: The dialog box that iTunes uses to ask for your password would be ideal. What is that called?
Well, you could use a UIAlertView including a UITextView.
Honestly, I'm not sure Apple will like it, because UIAlertView should only prompt message to inform the user, but it's at least kinda cool ;)
You can find a tutorial on this website : http://iphonedevelopment.blogspot.com/2009/02/alert-view-with-prompt.html
Use
[alert setAlertViewStyle:UIAlertViewStylePlainTextInput];
or
[alert setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
Hope it helps! Best of luck
精彩评论