- NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
- //UIKeyboardWillShowNotification键盘出现
- [defaultCenter addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
- //UIKeyboardWillHideNotification 键盘隐藏
- [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.width;
- }