I have 6 Textfields, and i don’t want to move the first 3 text fields up.but rest i want.When i click on 1 textfield it don’t move but when i click on 2,3 and so on textfield the view moves to down.
The code i have used:-
- (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];
}
}
You can check textfield names to perform animation on specific textfield.