監聽鍵盤的彈出與消失
阿新 • • 發佈:2019-01-04
//註冊鍵盤出現的通知
[[NSNotificationCenterdefaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardWillShowNotificationobject:nil];
//註冊鍵盤消失的通知
[[NSNotificationCenterdefaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification
- (void)keyboardWasShown:(NSNotification*)aNotification
{
//鍵盤高度
CGRect keyBoardFrame = [[[aNotification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
}
-(void)keyboardWillBeHidden:(NSNotification*)aNotification
{