标签:
1、系统键盘跟第三方输入法都可以用这个方法
// //增加监听,当键盘出现或改变时收出消息
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
//增加监听,当键盘出现或改变时收出消息
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
- (void) keyboardWillShow:(NSNotification *)notif
{
NSDictionary *info = [notif userInfo];
NSValue *value = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
keyBoardHeight = [value CGRectValue].size.height;
// [UIView animateWithDuration:0.3f animations:^{
// _appointCourseTV.contentOffset=CGPointMake(0, keyBoardHeight);
// } completion:nil];
}
//回收键盘并落下输入框
- (void)keyboardWillHide:(NSNotification *)notif
{
[_remarkTextView resignFirstResponder];
[UIView animateWithDuration:0.3f animations:^{
_appointCourseTV.contentOffset=CGPointMake(0, 0);
} completion:nil];
// [UIView animateWithDuration:0.3 animations:^{
//
// CGRect rect = CGRectMake(0, 0, M_S.width, M_S.height);
//
// self.view.frame = rect;
//
// }];
}
标签:
原文地址:http://www.cnblogs.com/huoxingdeguoguo/p/5037935.html