If the NSNotificationCenter statement in iOS

I'm trying to start a new animation when it's over.

I check the callbacks as follows:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(animationDidStopNotification:) name:ImageAnimatorDidStopNotification object:animatorViewController]; 

How to make an if statement that allows me to run something while getting ImageAnimatorDidStopNotification?

Thanks!

0
ios uikit animation core-animation
source share
2 answers

You have not posted enough code to find out what you are trying to do and where the problem is.

If you want to link two (or more) animations using UIKit, try using the setAnimationDidStopSelector: selector.

 - (void)startAnimating { [UIView beginAnimations: @"AnimationOne" context:nil]; [UIView setAnimationDuration:1.0]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(animationOneDidStop:finished:context:)]; /* animation one instructions */ [UIView commitAnimations]; } - (void)animationOneDidStop:(NSString*)animationID finished:(NSNumber*)finished context:(void*)context { [UIView beginAnimations: @"AnimationTwo" context:nil]; [UIView setAnimationDuration:1.0]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(animationTwoDidStop:finished:context:)]; /* animation two instructions */ [UIView commitAnimations]; } - (void)animationTwoDidStop:(NSString*)animationID finished:(NSNumber*)finished context:(void*)context { [UIView beginAnimations:@"AnimationThree" context:nil]; [UIView setAnimationDuration:1.0]; /* animation three instructions */ [UIView commitAnimations]; } 
0
source share

Linking animations together with animationDidStop is useful for very simple scenarios. However, for something more complicated, it quickly becomes cumbersome.

A better approach recommended by Apple is to use the CAMediaTiming protocol.

They provide a great example in WWDC 2011 videos of the 421 Basic Animation Basics session. You will find this in the link above. To do this, you will need a developer account.

Fast forward in the video at 42:36 for the “Notifications and time” tooltip.

+4
source share

All Articles