Reputation: 2237
I'm getting an intermittent problem where the keyboard won't show on a UITextField.
It happens most times, but not every time.
I really can't pinpoint the action that's causing it.
I've subscribed to UIKeyboardDidShowNotification
and the notification user data from that is:
0x15581730 {name = UIKeyboardDidShowNotification; userInfo = {
UIKeyboardAnimationCurveUserInfoKey = 0;
UIKeyboardAnimationDurationUserInfoKey = "0.25";
UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 0}}";
UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 568}";
UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 568}";
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{inf, inf}, {0, 0}}";
UIKeyboardFrameChangedByUserInteraction = 0;
UIKeyboardFrameEndUserInfoKey = "NSRect: {{inf, inf}, {0, 0}}";
}}
The NSRect: {{inf, inf}, {0, 0}}
seems to be the problem, as those two values are valid when the keyboard does show.
The app is pretty standard. It's a nav stack and this happens on a view controller about 4 levels down in the stack. All textfield delegates are set, and I can't see anything else strange about the view or controller.
Has anyone seen this before?
Upvotes: 2
Views: 940
Reputation: 721
Are you using DCIntrospect on iOS 5.x simulator? I got the same issue and found the wrong UIKeyboardFrameBeginUserInfoKey
value is caused by DCIntrospect. DCIntrospect may try to change the first responder when receiving UIKeyboardWillHideNotification
notifications. See the code:
- (void)takeFirstResponder
{
if (![self.inputTextView becomeFirstResponder])
NSLog(@"DCIntrospect: Couldn't reclaim keyboard input. Is the keyboard used elsewhere?");
}
Generally, we should never enable DCIntrospect on release version. So end users should not encounter this issue.
Upvotes: 0
Reputation: 146
can you remember any details about your app? I think it might be related to iOS 6's orientation API changes. I was having the same problem, as well as suffering from some unintuitive orientation behaviours.
Specifically, my app specified UIInterfaceOrientationMaskPortraitUp
as the only permissible orientation in both the Info.plist and also in the root UIViewController's supportedInterfaceOrientations:
implementation. I was also returning NO
all the time for shouldAutorotate
from my root UIViewController. I was using the UIDevice's orientation to determine how to present my child UIViewControllers and setting the status bar orientation with a function of the type of UIViewController being presented and the UIDeviceOrientation.
This was causing a fairly straightforward but on iPad (this is an iPhone app) whereby when started from a landscape-oriented launchpad the presented UIViewController (and status bar) would be oriented perpendicular to the window frame, and would not rotate back.
It also caused some very bizarre intermittent orientation / window frame bugs on iPhone 3GS where the frame of the RootViewController was being given some stupid dimensions way larger than the device.
What I changed (in my root UIViewController):
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutomaticallyForwardRotationMethods
{
return NO;
}
I also no longer use the device orientation to determine the correct orientation, relying solely on the class of UIViewController being presented (decided by the navigation). This had the expected effect of solving the straightforward iPad orientation bug, but I have seen no instances of the bizarre intermittent bug OR the keyboard bug you were also having.
Upvotes: 4
Reputation: 403
set
@interface UIController : UIViewController<UITextFieldDelegate>
and assign Data delegate to your UITextfield from Xib..
Upvotes: -1