I got a TextView
that is supposed to show upon a button press, and let the user enter text through the keyboard.
- (IBAction) changeName {
changeNameBtn.hidden = YES;
backBtn.hidden = YES;
usernameLabel.hidden = NO;
inputTextField.hidden = NO;
[inputTextField becomeFirstResponder]; // to show keyboard
}
This works fine for most of us.
But the Keyboard does not show for some of my testers, at a geographically remote location. How to trouble shoot this? And what could be the reason for the different behavior of our devices? It works fine for me and everybody else. We all use the same devices (iPod, iOS 4.1 - 5.1).
First thing I tried did not work:
I guessed that the inputTextField did in some way not become visible in time, before becomeFirstResponder
was fired, so I added setNeedsDisplay
as I thought that would force an update.
[inputTextField setNeedsDisplay];
[inputTextField becomeFirstResponder];
Second thing I tried did not work:
if([inputTextField canBecomeFirstResponder]){
[inputTextField becomeFirstResponder];
}
Third thing I tried is a workaround, requiring the unlucky user to press the field:
- (IBAction) inputTextFieldTouch {
[inputTextField becomeFirstResponder];
}
This workaround works, but there must be a better way. Please enlighten me about what I am doing wrong! :) And how to approach issues like this without being able to duplicate it myself?
I called becomeFirstResponder
later by this line:
[self.searchBar performSelector:@selector(becomeFirstResponder)
withObject:nil
afterDelay:0.1f];
It worked for me. Hope this help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With