2

I try this in viewDidAppear but i have a one second of delay =( what can i do? for work in viewDidLoad?

-(void)viewDidAppear:(BOOL)animated{


            fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
            fullRotation.fromValue = [NSNumber numberWithFloat:0];
            fullRotation.toValue = [NSNumber numberWithFloat:((720*M_PI)/360)];
            fullRotation.duration = 5;
            //  fullRotation.repeatCount = 1e10f;
            [_propImaCirculoCompleto.layer addAnimation:fullRotation forKey:@"360"];


}
2
  • 1
    Putting it in viewDidLoad is probably not what you want. Try viewWillAppear. Are you doing anything else when the view appears that might be taking a lot of cpu cycles? Sep 26, 2013 at 16:58
  • Why are you using an animation block? Run all that code outside. And don't forget to call [super viewDidAppear:]. Even though it does nothing for standard UIViewController classes, it's good practice :)
    – Guy Kogus
    Sep 26, 2013 at 17:12

2 Answers 2

5

You shouldn't do any animation in viewDidLoad as the view won't have a superview yet so the animation is irrelevant.

A few thoughts on your code sample:

  • You can use viewDidAppear as long as you want the animation every time the view appears, not just the first time it is presented.

  • Using Core Animation within an animation block isn't necessary. Do one or the other.

Suggestions

If you are trying to animate the appearance of a view managed by a different view controller, the presenting controller is responsible for the animation. There are a few ways to implement this depending on your minimum supported version of iOS.

  • In iOS 5+ you can use a custom container controller to present a child view controller with a defined animation.

  • In iOS 7 you can use 'presentViewController:animated:completion' and specify a custom animation. You would then set the transitioningDelegate property and have the delegate provide the animator for the transition.

I don't have ready sample code for the above but that's what I would look at.

1
  • Ok if you have a code sample to accomplish this please help me hehehe
    – Fabio
    Sep 26, 2013 at 19:50
-1

Try to split Your animation by two 180 degree rotations. Seems that iOS 7 is lazy and wan't rotate by 360 :)

2
  • 1
    Thats because full rotation is zero rotation.
    – Sulthan
    Sep 26, 2013 at 17:13
  • This doesn't attempt to answer the question
    – Tim
    Sep 26, 2013 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.