2

I have a UIViewController that should control 2 UIImageViews to fade in.

I managed to animate them using the UIView animateWithDuration method, like this:

[UIView animateWithDuration:1.5
    animations:^{
      [mFrontpageTitle setAlpha:0];
      [mFrontpageTitle setAlpha:1];
    }
    completion:^(BOOL finished){
      [self AnimatePause];
    }];

and

-(void)AnimatePause {
[UIView animateWithDuration:5.0
    animations:^{
      [mFrontpageTitle setAlpha:0.99];
      [mFrontpageTitle setAlpha:1];
    }
    completion:^(BOOL finished){
      [self AnimateAuthor];
    }];

which fires the next animation. Now, creating a transition from .99 to 1.0 is not very clean.

Is there a better way to trigger a block or sending a message by just defining a duration?

thanks

Zuppa

Zuppa
  • 23
  • 3

1 Answers1

3
NSTimeInterval delay = 1.5; //in seconds
[self performSelector:@selector(myMethod) withObject:nil afterDelay:delay];
omz
  • 53,243
  • 5
  • 129
  • 141
  • Thanks. I have look into the completely wrong direction. I will see if this crashes if the UIView is being removed before the interval is complete.. :) – Zuppa Aug 21 '11 at 11:56
  • what if I want to call a method that takes two parameters?? like, for instance: `- (void) MoveSomethigFrom:(id)from To:(id)to;` – Frade Mar 09 '12 at 13:13
  • Either wrap your method in something that just takes one parameter (e.g. a dictionary with all the parameters), or use `dispatch_after` (see [here](http://stackoverflow.com/a/4139331/573626) for an example). – omz Mar 09 '12 at 13:28