keyboardWillShow called twice

前端 未结 3 744
暗喜
暗喜 2021-01-02 07:32

I have a view with keyboard notifications such as keyboardWillShow and keyboardWillHide

All the codes handles with the notification I use i

3条回答
  •  执笔经年
    2021-01-02 07:43

    It is called twice on iOS 8 when a custom keyboard, like SwiftKey is being shown.

    On the first call, it probably prepares to show, so CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; will have a keybaord height of 0.

    The second call will have the correct keyboard height, so if you need to adjust content insets, you can check that the height of keyboard returned is > 0 before calculating your insets.

    Also, it will be called whenever user changes keyboard.

提交回复
热议问题