user88382
user88382

Reputation:

Clearing all text fields in xcode

Is there a way of clearing all test fields when selecting a text field to enter text with the keyboard.

For instance if you had a tip calculator that you have already run once, and all the fields are now populated.

Now when you want to run another calculation, you click on the text field an all the other fields are automatically cleared also.

Hope this makes sense. Steve

Upvotes: 0

Views: 1740

Answers (2)

cdespinosa
cdespinosa

Reputation: 20799

You probably want to tag this (and your subsequent questions) "cocoa-touch", because they're about the use of the APIs in the Cocoa Touch framework for the iPhone OS, rather than "xcode" (which is just a development tool).

Upvotes: 0

Don McCaughey
Don McCaughey

Reputation: 9982

Your view controller should implement the UITextFieldDelegate protocol. Then add the -textFieldShouldBeginEditing: or -textFieldDidBeginEditing: method to your view controller. In your nib file or when you create your text fields, set their delegate properties to your view controller.

Then when the -textFieldShouldBeginEditing: or -textFieldDidBeginEditing: method is called, you can clear all your text fields if you're app is ready to start a new calculation.

Upvotes: 1

Related Questions