In Xcode4 I\'ve created some placeholder text for a UITextField and I\'d like it to clear when the user taps in the box.
So, in the Attributes Inspector for the text fie
You should also check if text filed is empty then you should put place holder again
- (void)textFieldDidBeginEditing:(UITextField *)textField {
textField.placeholder = nil;
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
if ([textField.text isEqualToString:@""] || [[textField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] == 0))
{
[textField setText:@""];
textField.placeholder = @"Your Placeholdertext";
}
}