UIKeyboardFrameBeginUserInfoKey/UIKeyboardFrameEnd

2019-08-16 13:57发布

问题:

It is possible to read the following in the apple Documentation:

UIKeyboardFrameBeginUserInfoKey The key for an NSValue object containing a CGRect that identifies the start frame of the keyboard ……

UIKeyboardFrameEndUserInfoKey The key for an NSValue object containing a CGRect that identifies the end frame of the keyboard ……

Would that mean that the keyboard has a "start frame" and an "end frame"? I suppose YES.

But when the keyboard appears I cannot see any frame changing. It just stays the same frome start to end.

So my question is: What are those "start frame" and "end frame" referring to? I must be missing something.

Thanks for your help.

回答1:

The keyboard does indeed have a start and end frame, and the properties do exactly what you suppose they do. They keyboard does not always animate however; sometimes it just appears or changes size. For example, in the case that you are typing on the Japanese keyboard, when the keyboardWillShow fires after the first character is hit. There's no animation, but an additional bar appears above the keyboard, thus changing the size. The properties you listed above tell you how much the keyboard changed size by.

I'm not sure what exactly you're looking at when you say no frames are changing. I suppose it's possible that when you move from one editable text field to another, you get a keyboardWillShow notification, even though nothing on the screen changes.