I'm debugging someone else's code - sorry I have very limited Objective-C experience.
#pragma mark - Keyboard events
- (void)keyboardWasShown:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
NSLog(@"Keyboard a Notification user Info %@", info);
printf("keyboardWasShown \\\\\\\\\\\\\\\\\\\\\n");
NSLog(@"textInputView: y: (%.f), height: (%.f), kbHeight: (%.f)",
textInputView.frame.origin.y, textInputView.frame.size.height, kbSize.height);
[UIView animateWithDuration:2.0f animations:^{
if (keyboardNewLine){
bubbleTableFrame = originalBubbleTableFrame;
}
CGRect frame = originalTextViewFrame;
int difference = 0;
if (IsIphone5){
difference = -42;
frame.origin.y -= kbSize.height + difference;
} else {
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f) {
difference = 42;
frame.origin.y -= kbSize.height + difference;
} else {
frame.origin.y -= kbSize.height + 110;
difference = 42;
}
}
textInputView.frame = frame;
frame = bubbleTableFrame;
frame.size.height -= kbSize.height + difference;
bubbleTable.frame = frame;
}];
NSLog(@"textInputView: y: (%.f), height: (%.f), kbHeight: (%.f)",
textInputView.frame.origin.y, textInputView.frame.size.height, kbSize.height);
printf("keyboardWasShown //////////\n");
[bubbleTable scrollBubbleViewToBottomAnimated:YES];
}
When I tap the text input field to bring up the keyboard, the field should move up to just above the keyboard - sometimes. It all depends on the which keyboard is loading first.
- The text field without keyboard:
- After tapping the text field, I expect:
- However the text field stays at the bottom of the screen, leaving only the placeholder:
- Strange enough, if I drag down the QuickType row, the text field suddenly appears!
- But if I exit from this view and come back afterwards, once again the text field is stuck at the bottom (and guess what, it jumps up if I drag UP the QuickType row):
- Switching to another keyboard (input method) by tapping the globe icon always helps to bring up the text field:
- It seems that third-party keyboards are not affected:
You can see that I keep monitoring textInputView.frame.origin.y to see what goes wrong. It changes from 472 (no keyboard) to 261 (English keyboard) but the text field simply doesn't go up.
I don't think it is behind the placeholder (if any) because when I tap the white area beside the bubbles, the keyboard moves down and unveils the text field stuck at the bottom.
Someone suggested adding setNeedsDisplay, setNeedsLayout, etc. but none helped.
Thanks in advance.