I have a class that needs to ask the user a question and wait for the users response to determine the next action. What would be the best way to do this? Using a delegate? How? I have a UITextField and a UITextField in the class.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It all depends upon how you wish for the user to submit the data. The most user friendly way is to do as TahoeWolverine explained and implement
- (BOOL)textFieldShouldReturn:(UITextField *)textFieldfromUITextFieldDelegate. In order to use this, the class that implementstextFieldShouldReturn:must have<UITextFieldDelegate>protocol in its interface declaration; moreover, the textfield in question must have theUITextFieldDelegate-implementing class set as its delegate. In most cases those would look like this:and somewhere in the implementation:
Finally, implementing the
UITextFieldDelegateprotocol:Hope that helps.