我有 6 个文本字段,我不想将前 3 个文本字段向上移动。但我想要休息。当我点击 1 个文本字段时它不会移动,但是当我点击 2,3 等文本字段时,视图向下移动。
我使用的代码:-
- (void) animateTextField: (UITextField*) textField up: (BOOL) up
{
const int movementDistance = 105;
const float movementDuration = 0.3f;
int movement = (up ? -movementDistance : movementDistance);
[UIView beginAnimations: @"anim" context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
self.view.frame = CGRectOffset(self.view.frame, 0, movement);
[UIView commitAnimations];
}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
if (textField==txtname) {
toolphone.hidden = YES;
}
if (textField==txtcompanyname) {
toolphone.hidden = YES;
}
if (textField==txtemail) {
toolphone.hidden = YES;
}
if (textField ==txtsubject) {
toolphone.hidden = YES;
}
if (textField ==txtphone) {
[txtphone resignFirstResponder];
toolphone.hidden = NO;
}
if (textField ==txtmessage) {
toolphone.hidden = YES;
[self animateTextField: textField up: YES];
}
}