Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are iOS animations slow the first time they are run?

It seems to me that the first time I run an animation (animating the frame of a UIView, or the position of a CALayer, etc) it is quite choppy, and subsequent animations are smooth.

What would be causing this, and is there any way to pre-cache the animation?

Note: this question is quite similar to this one: UIImageView animations lag at first run, but UIImages are not being used in my animations.

like image 956
ryleigh Avatar asked Nov 07 '11 23:11

ryleigh


1 Answers

If you have a TextField, which I assume is what receives your user input. Use the UITextFieldDelegate methods Did and not Should

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
//Do textfield animations and other view animations here

}

Don't do your animations in;

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
//Don't do textfield animations and other view animations here
//This is where the system does its own animations; raising the keyboard, etc
}

like image 148
Majid Avatar answered Nov 03 '22 06:11

Majid