0
votes

I am facing a strange behavior in UIView animation. I am developing an iPad application which is using some UIView animations.

The duration of all animation is set to 0.5. Initially on launching the application all animations are working fine. But after some continuous use no animation is happening, all UIView changes are happening quickly, just like the duration is not set in animation.

I am not sure why this is happening. Has anyone else faced this kind of issue?

Following is one of the animation I am using. Like this I am using a lot of animations but after some time none of the animation is happening but all the codes inside the animation block is working fine

[UIView animateWithDuration:0.5 animations:^{ 
    [tempLabel setFont:titleFont.font]; 
    [tempLabel setTransform: CGAffineTransformMakeRotation((-90 * M_PI / 180))]; 
    tempLabel.frame = CGRectMake(2,0,23,30);   
}];
2
If you can show some code, it will be easier to tell..iphonic
Following is one of the animation i am using .Like this I am using a lot of nimations but after some time none of the animation is happening but all the codes inside the animation block is working fine [UIView animateWithDuration:0.5 animations:^{ [tempLabel setFont:titleFont.font]; [tempLabel setTransform:CGAffineTransformMakeRotation((-90 * M_PI / 180))]; tempLabel.frame = CGRectMake(2,0,23.30); }MobX
It's not very convenient to read code that isn't correctly formatted, let alone in a comment. Surround code in backticks ` so it's actually readable.Greg
ok..I just fond that in this situation if i click on a text field,then the animation in showing the keyboard also is not happening.Any clues??MobX
I m suspecting that the reference of you controls getting animated are having some problem, may be they are getting nil, something else. Check with breakpoints..iphonic

2 Answers

2
votes

From the UIView class reference, the frame property:

Changes to this property can be animated. However, if the transform property contains a non-identity transform, the value of the frame property is undefined and should not be modified. In that case, you can reposition the view using the center property and adjust the size using the bounds property instead.

Don't animate the frame when you've also set a transform. Use bounds and center instead.

1
votes

The problem you have seems that you are transforming the control every time, when you apply a transformation for the first time, there is no transformation on control, but next you have a transform, in this case the next transformation may not work as you want.. You have few options to solve this as follows, I haven't tried the code it might work

tempLabel.transform = CGAffineTransformIdentity; 

Put the above code before applying any transformation this will reset any transformation applied and your new transformation will be freshly applied or, you can do

tempLabel.transform = CGAffineTransformConcat(tempLabel.transform, YOUR TRANSFORM);

The above will append to your last transformation..

Hope it helps.

Thanks.