Pergunta

I have a tabbed application and when I click on the second tab, an animation should be performed and then other operations should be executed. I have implemented the animation with [imageView startAnimating]; and everything works well. The problem is that I don't know how to intercept the end of the animation process, in order to perform other operations. I know that UIImageView has no delegate methods. I know that the imageView.isAnimating property is not useful. I know that using a NSTimer, the operation is executed at the end of timer, even if, for example, in my case the user has changed tab.

Any ideas on how to solve this issue? How to intercept the end of the animation?

Foi útil?

Solução

I believe using an NSTimer is the only way to get the behavior you want. However, when the timer fires, I would include a check in whatever method gets called to make sure the tab you're talking about is still open; or you could invalidate the timer once the user changes tabs.

Outras dicas

Try thse when you are loading your UIImageView:

[UIView transitionWithView: destinationView
           duration:0.2f
           options:UIViewAnimationOptionTransitionFlipFromLeft
           animations:^ {
              //Funky Animation 
           } 
           completion:^(BOOL finished) {
               if(finished) {
                   //Funky Completion Code
               }
           }];

or

[UIView transitionFromView: startView
           toView: destinationView
           duration:0.2
           options:UIViewAnimationOptionTransitionFlipFromLeft
           animations:^ {
              //Funky Animation 
           } 
           completion:^(BOOL finished) {
               if(finished) {
                   //Funky Completion Code
               }
           }];

       completion:NULL];
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top