- (void)registerForKeyboardNotifications{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardWillChangeFrameNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasHidden:)
name:UIKeyboardWillHideNotification
object:nil];
}
- (void)keyboardWasShown:(NSNotification *)notif{
CGRect keyboardEndFrameWindow;
[[notif.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] getValue: &keyboardEndFrameWindow];
double keyboardTransitionDuration;
[[notif.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] getValue:&keyboardTransitionDuration];
UIViewAnimationCurve keyboardTransitionAnimationCurve;
[[notif.userInfo valueForKey:UIKeyboardAnimationCurveUserInfoKey] getValue:&keyboardTransitionAnimationCurve];
CGRect keyboard = [self.view convertRect:keyboardEndFrameWindow fromView:nil];
CGRect rect=CGRectMake(0, ScreenHeight-keyboard.size.height-40, ScreenWidth, 40);
[UIView animateWithDuration:0.2 animations:^{
_sendMsgView.frame=rect;
}];
}
- (void) keyboardWasHidden:(NSNotification *) notif{
CGRect rect=CGRectMake(0, ScreenHeight-90, ScreenWidth, 40);
[UIView animateWithDuration:0.2 animations:^{
_sendMsgView.frame=rect;
}];
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardWillChangeFrameNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasHidden:)
name:UIKeyboardWillHideNotification
object:nil];
}
- (void)keyboardWasShown:(NSNotification *)notif{
CGRect keyboardEndFrameWindow;
[[notif.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] getValue: &keyboardEndFrameWindow];
double keyboardTransitionDuration;
[[notif.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] getValue:&keyboardTransitionDuration];
UIViewAnimationCurve keyboardTransitionAnimationCurve;
[[notif.userInfo valueForKey:UIKeyboardAnimationCurveUserInfoKey] getValue:&keyboardTransitionAnimationCurve];
CGRect keyboard = [self.view convertRect:keyboardEndFrameWindow fromView:nil];
CGRect rect=CGRectMake(0, ScreenHeight-keyboard.size.height-40, ScreenWidth, 40);
[UIView animateWithDuration:0.2 animations:^{
_sendMsgView.frame=rect;
}];
}
- (void) keyboardWasHidden:(NSNotification *) notif{
CGRect rect=CGRectMake(0, ScreenHeight-90, ScreenWidth, 40);
[UIView animateWithDuration:0.2 animations:^{
_sendMsgView.frame=rect;
}];
}