//检测到有键盘的时候 页面上移
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
if (textField == nameTF) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
}
return YES;
}
- (void)keyboardWillShow:(NSNotification *)notification{
whiteView.frame = CGRectMake(0,self.frame.size.height/16, self.frame.size.width/2, self.frame.size.height/8*3);
}
//键盘消失
- (void)keyboardWillHide:(NSNotification *)notification {
whiteView.frame =CGRectMake(0,self.frame.size.height/16*5, self.frame.size.width/2, self.frame.size.height/8*3);
}
网友评论