You can simple do it using the placeholder
property of UITextField
, but the text will appear as a little blurred manner, if you want to show the previous value then you can use the following solution:
You can do it using the textFieldDidEndEditing
delegate method.
- (void)textFieldDidEndEditing:(UITextField *)textField
{
if(textField.text.lenght == 0)
{
textField.text = yourPreviousText;
}
}
And in textFieldShouldBeginEditing
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
yourPreviousText = textField.text;
}
yourPreviousText is a NSString
object declared in the class scope.