I have written the below Logic for moving a view upwards when a textfiled begins its editing.It is working fine in iOS 7 but it is not working in iOS 8.
Code:
-(void)viewDidLoad
{
_leagalName.delegate = self;
_phoneNumber.delegate = self;
_email.delegate = self;
_contactName.delegate = self;
_contactNumber.delegate = self;
_password.delegate = self;
_confirmPassword.delegate = self;
}
-(void)animateTextField:(UITextField*)textField up:(BOOL)up
{
const float movementDuration = 0.3f; // tweak as needed
int movement = (up ? movementDistance : -movementDistance);
[UIView beginAnimations: @"animateTextField" context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
self.sampleView.frame = CGRectOffset(self.sampleView.frame, 0, movement);
[UIView commitAnimations];
}
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
if([textField isEqual:_leagalName])
{
movementDistance = 0;
[self animateTextField:textField up:YES];
}
else if([textField isEqual:_phoneNumber])
{
movementDistance = 0;
[self animateTextField:textField up:YES];
}
else if([textField isEqual:_email])
{
movementDistance = -40;
[self animateTextField:textField up:YES];
}
else if([textField isEqual:_contactName])
{
movementDistance = -80;
[self animateTextField:textField up:YES];
}
else if([textField isEqual:_contactNumber])
{
movementDistance = -110;
[self animateTextField:textField up:YES];
}
else if([textField isEqual:_password])
{
movementDistance = -140;
[self animateTextField:textField up:YES];
}
else if([textField isEqual:_confirmPassword])
{
movementDistance = -170;
[self animateTextField:textField up:YES];
}
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
[self animateTextField:textField up:NO];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
Can anyone please explain how i can move view upwards in iOS 8.
Aucun commentaire:
Enregistrer un commentaire