0

Can anyone think of a reason that a UITextField would resignFirstResponder, and then no longer respond to touches to becomeFirstResponder? I have a situation where I have a view controller that appears, but the keyboard disappears immediately, and the text field still has the cursor, but it's not blinking. Tapping on the text field will cause the "paste" menu option to appear and I can paste text into the field, but I cannot make it become first responder.

Any thoughts would be greatly appreciated...

SeanT
  • 1,741
  • 1
  • 16
  • 24
  • are you testing it on simulator? http://stackoverflow.com/questions/24420873/xcode-6-keyboard-does-not-show-up-in-simulator – Vlad Z. Oct 21 '14 at 21:34
  • No, it's an ad hoc build, and it's reproducible in iOS 7 & 8 on multiple devices. – SeanT Oct 21 '14 at 21:38
  • Does your code disable the editable property of the the textfield at any point? – Msencenb Oct 21 '14 at 22:30
  • No, that was my first thought. The editable property is never changed in the code. – SeanT Oct 23 '14 at 02:06
  • Click on the `Debug View Hierarchy` button while debugging. You will be able to get visual insights on the textField. (Possibly there is another invisible view on top of it?) – Lirik Jun 11 '19 at 17:39

1 Answers1

0

I've had to deliberately create this scenario before for a previous app and the way i did it was to set the input view for the textfield to a tiny dummy view.

UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];    
myTextField.inputView = view;

Although I believe this still showed the blinking cursor.

To get the blinking cursor to stop as well I had to return NO in the shouldBeginEditing method.

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    return NO; 
}

So if you are doing either of these things you would get the behaviour that you're currently experiencing where the textfield is actually responding but it is isn't showing a keyboard or a blinking cursor.

pbevis
  • 198
  • 2
  • 11