キーボードの動作によって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されることの認識
- いい方法が分からなかった。。