iOS get Keyboard Window

前端 未结 4 1202
一生所求
一生所求 2021-01-13 00:16

So in iOS 7 I always got the Keyboard Window like this:

- (UIView *)keyboardView
{
    UIWindow* tempWindow;

    //Because we cant get access to the UIKeybo         


        
4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-13 01:01

    What i use to get the window for the keyboard is

    - (void)findKeyboardWindow
    {
        for (UIWindow *window in [[UIApplication sharedApplication] windows])
        {
            if ([NSStringFromClass([window class]) isEqualToString:@"UITextEffectsWindow"])
            {
                _keyboardWindow = window;
                break;
            }
        }
    }
    

    From my logs on iOS8 this contains one view

    UIInputSetContainerView: 0x190d4430; frame = (0 0; 320 568); autoresize = W+H; layer = CALayer: 0x190d4630
    

    Which contains another view

    UIInputSetHostView: 0x190d4820; frame = (0 352; 320 216); layer = CALayer: 0x190d49c0
    

    Since those dimensions are 216.0f height i guess that is the keyboard. Was this what you where looking for?

提交回复
热议问题