您的位置:首页 > 移动开发 > IOS开发

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里面写着的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: