user1432813
user1432813

Reputation: 162

Clear text field box when tapped on iPhone

I have a text field that is editable by the user and it contains some example text saying "Tap here to enter details". I would like the text box to clear when the user taps it so that the user does not have to delete my example before inputting their message. Is there an easy way of doing this. The only thing I can think of is to make a separate view controller that it links to when the text box is touched buut this seems an awful way round something which I would have thought is rather simple. All help greatly appreciated.

Thank you in advanced.

Upvotes: 0

Views: 897

Answers (2)

Imirak
Imirak

Reputation: 1333

I know you've already got your answer, but there is an alternative using UITextField's delegate method textFieldDidBeginEditing: --

     - (void)textFieldDidBeginEditing:(UITextField *)textField {

textField.text = @"";

}

Upvotes: 0

Bala
Bala

Reputation: 2895

enter image description hereThere is a property for UITextField clearsOnBeginEditing

Upvotes: 4

Related Questions