Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying to do animation after fadeout completion but not work. #4

Closed
Nazgugu opened this issue Jun 7, 2014 · 4 comments
Closed

trying to do animation after fadeout completion but not work. #4

Nazgugu opened this issue Jun 7, 2014 · 4 comments

Comments

@Nazgugu
Copy link

Nazgugu commented Jun 7, 2014

I want to create the animation that the label shines first, then followed by fading out the text and then switching the image in an imageview and after the completion of switching image I want to shine some other text, and repeat this process forever. Yet I do not know why the completion block for fadeout is not called.
Here is some of my code:

  • (void)Animate
    {
    if (self.shineLabel.isVisible)
    {
    //NSLog(@"is visible");
    [self.shineLabel fadeOutWithCompletion:^{
    NSLog(@"text = %@",self.shineLabel.text);
    [self changeText];
    [self startAnimatingBackground];
    [self.shineLabel shineWithCompletion:^{
    [self Animate];
    }];
    //[self startAnimatingBackground];
    }];
    }
    else
    {
    [self.shineLabel shineWithCompletion:^{
    [self Animate];
    }];
    }
    }
  • (void)startAnimatingBackground
    {
    NSLog(@"start animating background");
    UIImage *image = [self.imageArray objectAtIndex:(count % [self.imageArray count])];
    [UIView transitionWithView:self.imageLayer1
    duration:2.0f
    options:UIViewAnimationOptionTransitionCrossDissolve
    animations:^{
    self.imageLayer1.image = image;
    }completion:^(BOOL finished)
    {
    NSLog(@"finished");
    count++;
    }];
    }
@FoodworksTeam
Copy link

Had the same problem. What is happening is that
self.completion = NULL;
is firing after the second completion block is set, but before the completion block is called.

Essentially you are erasing the block before it gets used. I took out the line above, and it works fine for me. You can handle the NULLing of the completion block yourself if need be.

Hope this helps

@zipme
Copy link
Owner

zipme commented Sep 3, 2014

@IchabodDee I should probably nullify the completion when the shine or fadeOut methods (the ones without completion block) got called instead of after the completion block is called. What do you think?

@FoodworksTeam
Copy link

@zipme That is a good way to handle it. Essentially what you are trying to avoid is the scenario where you call shine or fadeOut and a completion block is used when it shouldn't be.

setting self.completion to NULL when shine or fadeOut are called should do the trick. Thanks a ton for the Shine Label it saved me a bunch of time for sure. When my app hits the app store I'll link it over so you can see your code at work.

Take care zipme

@zipme
Copy link
Owner

zipme commented Sep 4, 2014

Thanks so much! And good luck with your app!

@zipme zipme closed this as completed Sep 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants