Check for split keyboard

后端 未结 4 1473
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-13 11:08

As many of you know iOS 5 introduced a slick split keyboard for thumb-typing. Unfortunately, I have some UI that is dependent on the normal full-screen keyboard layout. One

4条回答
  •  無奈伤痛
    2020-12-13 11:24

    This is the solution which works with iPad split keyboards (originally from the blog linked in Zeeshan's comment)

    [[NSNotificationCenter defaultCenter] 
      addObserverForName:UIKeyboardDidChangeFrameNotification
      object:nil
      queue:[NSOperationQueue mainQueue]
      usingBlock:^(NSNotification * notification)
     {
         CGRect keyboardEndFrame =
         [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
    
         CGRect screenRect = [[UIScreen mainScreen] bounds];
    
         if (CGRectIntersectsRect(keyboardEndFrame, screenRect))
         {
             // Keyboard is visible
         }
         else
         {
             // Keyboard is hidden
         }
    }];
    

提交回复
热议问题