diff --git a/KBKeyboardHandler/Classes/KBKeyboardHandler.m b/KBKeyboardHandler/Classes/KBKeyboardHandler.m index 14b4957..7d08e41 100644 --- a/KBKeyboardHandler/Classes/KBKeyboardHandler.m +++ b/KBKeyboardHandler/Classes/KBKeyboardHandler.m @@ -76,6 +76,8 @@ - (void)retrieveFrameFromNotification:(NSNotification *)notification - (void)notifySizeChanged:(CGSize)delta notification:(NSNotification *)notification { + assert(self.delegate); + NSDictionary *info = [notification userInfo]; UIViewAnimationCurve curve; @@ -84,15 +86,15 @@ - (void)notifySizeChanged:(CGSize)delta notification:(NSNotification *)notificat NSTimeInterval duration; [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] getValue:&duration]; - void (^action)(void) = ^{ - [self.delegate keyboardSizeChanged:delta]; - }; - - [UIView animateWithDuration:duration - delay:0.0 - options:curve - animations:action - completion:nil]; + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:[notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]]; + [UIView setAnimationCurve:[notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue]]; + [UIView setAnimationBeginsFromCurrentState:YES]; + + [self.delegate keyboardSizeChanged:delta]; + + [UIView commitAnimations]; } @end