I wrote this a series of code that move the UIIMAGE from CENTER to LEFT position then will appear two textfields afterward too. The animation worked fine however that UIIMAGE will move back to the original (CENTER) location after I tapped on either one textfield. Please advise.
Here my code:
-(void)moveLogoLeft{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelay:0.0];
img_CPLLogo.frame = CGRectMake(130.0f, 230.0f, img_Logo.frame.size.width, img_Logo.frame.size.height);
[UIView commitAnimations];
}
and making a `UIButton’ to trigger the action
-(IBAction)doShowTextfield:(id)sender{
[UIView animateWithDuration:0 animations:^{
[btm_welcome setAlpha:0];
img_Logo.frame = CGRectMake(100.0f, 230.0f, img_Logo.frame.size.width, img_Logo.frame.size.height);
}completion:^(BOOL completed){
[self showTextfield];
}];
}
}
What’s wrong with this?
Use
UITextField‘sdelegatemethod for your requirement: