你的位置:首页 > 操作系统

[操作系统]监听键盘 防止输入时覆盖掉textfiled


 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardwasChange:) name:UIKeyboardWillChangeFrameNotification object:nil];

 

- (void)keyboardwasChange:(NSNotification *)info

{

    CGRect keyFrame = [info.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];

    CGFloat tY = keyFrame.origin.y - self.view.frame.size.height - 64;

    

    self.view.transform = CGAffineTransformMakeTranslation(0, tY);

}