Search code examples
objective-ckeyboarduiwindow

keyboard changed height


![enter image description here][1]enter image description herekeyboard get out of screen at bottom little bit when i try to add window as subview having view inside it. How to fix it? Here is my code.

keyboardWindowFrame = nil;
keyboardWindowFrame = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
for(UIView* potentialKeyboard in keyboardWindowFrame.subviews)
{   // if the real keyboard-view is found, remember it.
    if([[potentialKeyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)
    {
        NSLog(@"Keyboard Frame: %@",NSStringFromCGRect(potentialKeyboard.frame));
        keyboard = potentialKeyboard;
        [keyboard addSubview:viewForGlobeEmoji];
        [self.view addSubview:keyboard];
    }
}

Here is attached screen shot:

now there is space between toolbar and keyboard after adding

  if([[potentialKeyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)
        {
            NSLog(@"potentialKeyboard: %@",NSStringFromCGRect(potentialKeyboard.frame));


            keyboard = potentialKeyboard;
            CGRect frame = keyboard.frame;
            frame.origin.y = 332;
            keyboard.frame = frame;
            [keyboard addSubview:viewForGlobeEmoji];
            [self.view addSubview:keyboard];

         }

Solution

  • you should set the frame of keyboard below this line:

    keyboard = potentialKeyboard;
    CGRect frame = keyboard.frame;
    frame.origin.y = xxx;
    keyboard.frame = frame