监控KeyBoard
[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyBoardWillShow:)name:UIKeyboardWillShowNotificationobject:nil];
[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyBoardWillHidden:)name:UIKeyboardWillHideNotificationobject:nil];
显示的实现
- (void) keyBoardWillShow:(NSNotification*) notification
{
NSDictionary *userInfo = [notificationuserInfo];
// Get the origin of the keyboard when it's displayed.
NSValue* aValue = [userInfoobjectForKey:UIKeyboardFrameEndUserInfoKey];
// Get the top of the keyboard as the y coordinate of its origin in self's view's coordinate system. The bottom of the text view's frame should align with the top of the keyboard's final position.
CGRect keyboardEndFrame = [aValueCGRectValue];
CGRect keyboardFrame = [self.viewconvertRect:keyboardEndFrame toView:nil];
CGFloat keyboardHeight = keyboardFrame.size.height;
}