17
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iPadのKeyboard Notificationの動作のまとめ

Posted at

キーボードの動作によってNotificationはどう変わるか

以下がどのタイミングで呼ばれるか検証した。

  • UIKeyboardWillShowNotification
  • UIKeyboardWillHideNotification
  • UIKeyboardWillChangeFrameNotification

Dock(通常)のKeyboardを起動するとき

  • UIKeyboardWillChangeFrameNotification
  • UIKeyboardWillShowNotification

Split / UnDockのKeyboardを起動するとき

  • UIKeyboardWillChangeFrameNotification

Dock(通常)のKeyboardをSplit / UnDockするとき

  • UIKeyboardWillChangeFrameNotification
  • UIKeyboardWillHideNotification

SplitのKeyboardをDock&Mergeするとき

  • UIKeyboardWillChangeFrameNotification
  • UIKeyboardWillChangeFrameNotification
  • UIKeyboardWillShowNotification

SplitのKeyboardをMergeするとき

  • UIKeyboardWillChangeFrameNotification

UnDockのKeyboardをSplitするとき

  • UIKeyboardWillChangeFrameNotification

UnDockのKeyboardをDockするとき

  • UIKeyboardWillChangeFrameNotification
  • UIKeyboardWillShowNotification

Dock(通常)のKeyboardを閉じるとき

  • UIKeyboardWillChangeFrameNotification
  • UIKeyboardWillShowNotification

Split / UnDockのKeyboardを閉じるとき

  • UIKeyboardWillChangeFrameNotification

Split Keyboardを動かす

  • UIKeyboardWillChangeFrameNotification

Split Keyboardを動かしている途中でframeの最下部まで到達する

  • UIKeyboardWillChangeFrameNotification(動かす)
  • UIKeyboardWillChangeFrameNotification(splitからDockに切り替わり)
  • UIKeyboardWillShowNotification

キーボードを開いた状態で回転させる

  • UIKeyboardWillChangeFrameNotification

分割キーボードが開いたことの認識

- (CGRect)wtd_convertedKeyboardFrameBeginInView:(UIView *)view
{
    return [view convertRect:[[[self userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue] fromView:nil];;
}

- (CGRect)wtd_convertedKeyboardFrameEndInView:(UIView *)view
{
    return [view convertRect:[[[self userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:nil];
}

- (BOOL)wtd_splitOrUnDockKeyboardIsShowingInView:(UIView *)view
{
    CGRect keyboardFrameBegin = [self wtd_convertedKeyboardFrameBeginInView:(UIView *)view];
    CGRect keyboardFrameEnd = [self wtd_convertedKeyboardFrameEndInView:(UIView *)view];

    return keyboardFrameEnd.size.height != 0 && keyboardFrameBegin.origin.y == [[self class] visibleHeight] && keyboardFrameEnd.origin.y + keyboardFrameEnd.size.height < [[self class] visibleHeight];
}

- (BOOL)wtd_splitOrUnDockKeyboardIsHidingInView:(UIView *)view
{
    CGRect keyboardFrameBegin = [self wtd_convertedKeyboardFrameBeginInView:(UIView *)view];
    CGRect keyboardFrameEnd = [self wtd_convertedKeyboardFrameEndInView:(UIView *)view];

    return keyboardFrameEnd.size.height != 0 && keyboardFrameEnd.origin.y == [[self class] visibleHeight] && keyboardFrameBegin.origin.y + keyboardFrameBegin.size.height < [[self class] visibleHeight];
}

#pragma mark - Private

+ (CGFloat)visibleHeight
{
    return IS_LANDSCAPE() ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.height;
}

DockからUnDock / Splitされることの認識

  • いい方法が分からなかった。。

参考

17
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?