iOS 系统 键盘的通知
2015-01-21 09:48
302 查看
- (void)keyboardWillShow:(NSNotification *)aNotification
{
//获取键盘的高度
NSDictionary *userInfo = [aNotification userInfo];
NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardRect = [aValue CGRectValue];
int height = keyboardRect.size.height;
self.view.frame=CGRectMake(0, -height+64, self.view.frame.size.width,self.view.frame.size.height);
}
//当键退出时调用
- (void)keyboardWillHide:(NSNotification *)aNotification
{
self.view.frame=CGRectMake(0,64,kScreenWidth,kScreenHeight);
}
嫒...宋博 09:45:06
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
//
//增加监听,当键退出时收出消息
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil]; 这是通知didLOad里面写着的
{
//获取键盘的高度
NSDictionary *userInfo = [aNotification userInfo];
NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardRect = [aValue CGRectValue];
int height = keyboardRect.size.height;
self.view.frame=CGRectMake(0, -height+64, self.view.frame.size.width,self.view.frame.size.height);
}
//当键退出时调用
- (void)keyboardWillHide:(NSNotification *)aNotification
{
self.view.frame=CGRectMake(0,64,kScreenWidth,kScreenHeight);
}
嫒...宋博 09:45:06
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
//
//增加监听,当键退出时收出消息
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil]; 这是通知didLOad里面写着的
相关文章推荐
- ios-day08-02(ios的通知机制:通知的发布、监听、移除,一些常见的系统通知、键盘状态的通知、通知和代理的异同)
- [iOS]利用通知实现监听系统键盘
- ios之让输入键盘隐藏消失的方法/以及系统通知的实现
- [iOS]利用通知实现监听系统键盘
- IOS学习笔记(8)UIPageViewController UIProgressView 监听和响应键盘通知
- 对iOS系统键盘的hack以及注意事项
- iOS成长之路-获取系统键盘的高度
- IOS: iPhone键盘通知与键盘定制
- 订制ios系统键盘的特定按钮
- iOS开发之系统后台运行弹出本地通知
- IOS_系统键盘判断删除按钮被按下
- iOS核心系统编程最佳实践:通知
- iOS键盘中英文切换键盘高度获取通知方法
- ios本地化系统文字的方法,比如键盘的send本地化为发送
- iOS——tableView和适配、键盘弹出发送通知问题
- ios键盘通知和自定义键盘
- IOS开发之自定义系统弹出键盘上方的view
- CSS 仿 iOS 系统通知数字样式
- iOS中的系统通知
- iOS中的系统通知