1.先監控鍵盤出現的事件 :
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UIKeyboardWillShowNotification object:nil];
2.在監控觸發的方法裏獲取鍵盤的高度:-(void)keyBoardWillShow:(NSNotification *)notification{
NSLog(@"notification is %@ ",notification);
NSDictionary *dic=[notification userInfo];
NSValue *value=[dic objectForKey:@"UIKeyboardFrameEndUserInfoKey"];
CGRect rect=[value CGRectValue];
UIView *view=[self viewWithTag:2002];
CGFloat keyBHeight=rect.size.height;
//根據鍵盤高度進行判斷 做一些處理 比如是否遮蓋輸入框等問題 計算
}
}