Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextField text disappears on every other keystroke

Here is a video of the phenomena: http://youtu.be/c0TP8YVF9TE

As the video shows, the value in exampleTextView.text is not lost. Its just hidden every other keystroke.

Solutions tried: I do not set the exampleTextView.text value to something during the program, except after the return key is pressed (and commenting that line out changes nothing).

I have set:

self.exampleTextView.clearsOnBeginEditing=NO;
self.exampleTextView.clearsContextBeforeDrawing=NO;
self.exampleTextView.clearsOnInsertion=NO;

Edit: Here is my code: https://gist.github.com/andrewschreiber/6970283

like image 337
Andrew Schreiber Avatar asked Oct 14 '13 02:10

Andrew Schreiber


3 Answers

I had almost the same problem. Sometimes the text was disappearing.

I solved it after changing the position of the UITextField in the view hierarchy in the xib file.

enter image description here

like image 198
SbClx Avatar answered Oct 30 '22 05:10

SbClx


I was facing the same problem. My solution was to remove [_textField becomeFirstResponder] from the - (void)viewWillAppear:(BOOL)animated method. This bug only occurs if the viewcontroller was presented modally.

like image 36
René Fischer Avatar answered Oct 30 '22 06:10

René Fischer


Moving the UITextField's becomeFirstResponder from viewWillAppear to viewWillLayoutSubviews fixed this for my case. I also made sure to add resignFirstResponder on the UITextField to the actions that were dismissing the view (which was presented modally).

like image 20
user3339688 Avatar answered Oct 30 '22 05:10

user3339688