Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIKeyboardFrameBeginUserInfoKey

What is the diffefence between UIKeyboardFrameBeginUserInfoKey and UIKeyboardFrameEndUserInfoKey ?

Does that mean that the "begin" one returns a value that differs from what the "end" one returns?

Thanks !

like image 599
Wang Liang Avatar asked Nov 09 '11 13:11

Wang Liang


1 Answers

The UIKeyboardFrameBeginUserInfoKey will return the frame of the keyboard before the animation begins. The UIKeyboardFrameEndUserInfoKey will return the frame of the keyboard after the animation has completed. As an example, take the following snippet of code:

NSDictionary* info = [notification userInfo];
CGRect beginFrame = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGRect endFrame = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];

If you were to print the values of beginFrame and endFrame in the debug window, you might find something like this:

(gdb) print beginFrame
$1 = {
   origin = {
     x = 0, 
     y = 480
   }, 
   size = {
     width = 320, 
     height = 216
   }
 }
 (gdb) print endFrame
 $2 = {
   origin = {
     x = 0, 
     y = 264
   }, 
   size = {
     width = 320, 
     height = 216
   }
 }

So on an iPhone, this is showing that the keyboard will animate in from the bottom of the screen. The size of the keyboard doesn't change (as expected), but the y co-ordinates show the beginning and ending position of the keyboard.

like image 103
MikeG Avatar answered Nov 15 '22 15:11

MikeG