Get the height of keyboard doesn't work on IOS 11 beta

后端 未结 3 1426
故里飘歌
故里飘歌 2021-02-19 01:25

I have the following code which worked on IOS 10, but now it doesn\'t work anymore when running on IOS 11 beta.

if let userInfo = notification.userInfo {
    if          


        
3条回答
  •  眼角桃花
    2021-02-19 02:28

    Use UIKeyboardFrameEndUserInfoKey instead of UIKeyboardFrameBeginUserInfoKey

    So changing your code to the following will fix your issue:

    if let userInfo = notification.userInfo {
        if let keyboardSize = (userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
            print(keyboardSize)
        }
    }
    

提交回复
热议问题