Reputation: 943
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 !
Upvotes: 8
Views: 5223
Reputation: 4035
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.
Upvotes: 13