If I have multiple text fields and would like to have a button that clears all text fields at once, what tutorials or direction should I look into doing this? Any help would be greatly appreciated.
Share
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.
You start by putting a handler on that button (Touch Up Inside event). Then, you have several approaches.
You can have an outlet for each text box, in the handler, you set the text property to nil for each.
You can scroll through the subviews collection of your view, and for each textbox you encounter, set set the text property to nil. This leaves no textbox on the view untouched. You will have to recurse if the view hierarchy is nested.
You can assign numeric tags in a certain range to each textbox, then you go through the range, retrieve the view by tag and set text to nil. This is how it’s normally done in Win32 API, in case you care.