텍스트 필드가 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];
}
}