ios自定义键盘高度
2014-07-07 17:50
399 查看
//增加监听,当键盘出现或改变时收出消息
[[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 *)aNotification
{
//获取键盘的高度
NSDictionary *userInfo = [aNotification userInfo];
NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardRect = [aValue CGRectValue];
int height = keyboardRect.size.height;
self.contentTextView.frame = CGRectMake(self.contentTextView.left, self.contentTextView.top, self.contentTextView.width, self.view.height - self.contentTextView.top -
height);
}
////当键退出时调用
- (void)keyboardWillHide:(NSNotification *)aNotification
{
self.contentTextView.frame = CGRectMake(self.contentTextView.left, self.contentTextView.top, self.contentTextView.width, self.view.height - self.contentTextView.top - 100);
}
[[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 *)aNotification
{
//获取键盘的高度
NSDictionary *userInfo = [aNotification userInfo];
NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardRect = [aValue CGRectValue];
int height = keyboardRect.size.height;
self.contentTextView.frame = CGRectMake(self.contentTextView.left, self.contentTextView.top, self.contentTextView.width, self.view.height - self.contentTextView.top -
height);
}
////当键退出时调用
- (void)keyboardWillHide:(NSNotification *)aNotification
{
self.contentTextView.frame = CGRectMake(self.contentTextView.left, self.contentTextView.top, self.contentTextView.width, self.view.height - self.contentTextView.top - 100);
}
相关文章推荐
- iOS 获得键盘的高度 NSNotificationCenter
- iOS开发中的键盘高度变化处理
- iOS开发中的键盘高度变化处理
- IOS开发之自定义系统弹出键盘上方的view(转载)
- iOS开发 关于键盘高度
- ios 判断文字高度,适用于tableview的自定义高度
- iOS开发键盘高度的处理
- ios 动态监听键盘输入法和高度
- ios 动态监听键盘输入法和高度
- iOS 自定义键盘
- IOS开发之自定义系统弹出键盘上方的view
- ios键盘高度
- ios键盘高度
- iOS 获得键盘的高度 NSNotificationCenter
- 状态键盘完美适应iOS中的键盘高度变化
- iOS开发中的键盘高度变化处理
- iOS相应键盘高度变化,相应控件随之变化的代码段
- IOS自定义的数字键盘 FPNumberPadView
- iOS键盘高度自适应(中英文输入)
- iOS 自定义Cell 自适应高度