监控KeyBoard
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(keyBoardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(keyBoardWillHidden:)
name:UIKeyboardWillHideNotification
object:nil];
显示的实现
- (void) keyBoardWillShow:(NSNotification*) notification
{
NSDictionary *userInfo = [notification
userInfo];
// Get the origin of the keyboard when it's displayed.
NSValue* aValue = [userInfo
objectForKey: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 = [aValue
CGRectValue];
CGRect keyboardFrame = [self.view
convertRect:keyboardEndFrame toView:nil];
CGFloat keyboardHeight = keyboardFrame.size.height;
}