How to make text field first responder and not delete text? iPhone
When I make a text field first responder it deletes my default text. I want this text to stay until the user enters something.
The end result that I am looking for is that I want the keyboard to appear on the screen and default instructions to still appear until user clicks a button on the keyboard... at which time it should clear de开发者_开发百科fault text.
I tried making the textfield first responder when the view loads... this allows me to show the keyboard... but it clears out my instructional text.
In interface builder remove the checked for the "clear when editing begins" and in the textFieldDidBeginEditing method
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
[textField1 clearsOnBeginEditing];//textField1 is the instance of your text field.
}
All the Best.
精彩评论