[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}
#pragma mark - notif
- (void)keyboardWillShow:(NSNotification *)notification
{
NSDictionary* info = [notification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
[UIView animateWithDuration:[info[UIKeyboardAnimationDurationUserInfoKey] doubleValue]
delay:0
options:([info[UIKeyboardAnimationCurveUserInfoKey] integerValue]<<16)
animations:^{
_tableFooterLayout.constant = 60 + kbSize.height;
}
completion:nil];
}
- (void)keyboardWillHide:(NSNotification *)notification {
NSDictionary* info = [notification userInfo];
[UIView animateWithDuration:[info[UIKeyboardAnimationDurationUserInfoKey] doubleValue]
delay:0
options:([info[UIKeyboardAnimationCurveUserInfoKey] integerValue]<<16)
animations:^{
_tableFooterLayout.constant = 60;
}
completion:nil];
}