0

![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];

         }
4

2 回答 2

0

you should set the frame of keyboard below this line:

keyboard = potentialKeyboard;
CGRect frame = keyboard.frame;
frame.origin.y = xxx;
keyboard.frame = frame
于 2012-10-19T09:53:31.807 回答
0

Doing something like this is simply wrong and won't be well received by appstore reviewers. You are tampering with undocumented system APIs and this is only the result of an unexpected behavior.

There are standard ways how to do what you want:

  1. Keyboard notifications to check keyboard size and position.
  2. [UIResponder inputView]
于 2012-10-19T10:02:46.717 回答