I added a UITextField to my storyboard:
@property (weak, nonatomic) IBOutlet UITextField *nameField;
And it was working fine at first, but had some constraint issues which caused the view to not build correctly on an iPhone 5. So I messed with some of the constraints to get it to display correctly and now the keyboard never comes up/the UITextField refuses to respond to touches OR become active.
I tried setting a UITapGestureRecognizer
to the nameField, didn't work.
I made sure there were no views blocking it (checked on the view debugger, and then explicitly called [self.view bringSubviewToFront:self.nameField];
in viewDidAppear
)
I tried [self.nameField setUserInteractionEnabled:YES];
as well because why not.
So then I went to the storyboard, clicked on the text field and under the connection tab on the right side menu I looked at "Sent Events" and hooked up Touch Up Inside to an IBAction method:
- (IBAction)beginNameEdit:(id)sender {
NSLog(@"Edit begin");
BOOL accepted = [self.nameField becomeFirstResponder];
if (accepted) {
NSLog(@"accepted");
}
}
Nothing happens, (Edit begin did not print). (I touched up inside the boundary as well for sure, but whatever)
So then I hooked up Touch Down to the same exact IBAction.
This time, I started getting 'Edit begin' to print but the call to become first responder did nothing despite accepted actually getting printed (which means that according to Apple, the text field accepted first responder status)
I can't seem to make my textField active and so it's forever stuck on showing the placeholder text... It makes no sense, especially because I would be shocked if playing with some of the auto layout constraints could have any sort of effect.
Any suggestions?
Ok, and in classic the-answer-is-the-last-thing-you'd-expect fashion:
I was using the simulator to test the app. Turns out the keyboard doesn't always come up when you're using the simulator because it auto-detects the fact you have an ACTUAL keyboard on the computer you are using. So instead of a keyboard coming up on the simulator it was silently becoming the first responder and waiting for me to type something on my computer's keyboard.
Why the keyboard was coming up earlier and not now, I have no clue. But I'll leave this up in case anyone else comes across this issue.