注册通知
-(void)initNotiy{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame1:) name:UIKeyboardWillChangeFrameNotification object:nil];//在这里注册通知
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden1:)
name:UIKeyboardWillHideNotification object:nil];
}
#pragma mark-notif
- (void)keyboardWillChangeFrame1:(NSNotification *)notification
{
[UIView animateWithDuration:0.3 animations:^{
CGRect rect = _tableView.frame;
rect.origin.y = 64;
rect.size.height = self.view.frame.size.height - 64-226-60;
_tableView.frame = rect;
}];
}
-(void)keyboardWillBeHidden1:(NSNotification*)aNotification
{ [self.view endEditing:YES];
CGRect rect = _tableView.frame;
rect.origin.y =64;
rect.size.height = self.view.frame.size.height-64-60 ;
_tableView.frame = rect;
[self.tableView endEditing:YES];
}
-(void)dealloc{
[[NSNotificationCenter defaultCenter]removeObserver:self];
}