Domanda

I have a method called by performSelector:withObject:afterDelay:, which performs animation with duration. So after the delay, animation runs but without animation duration:

[self performSelector:@selector(animate:) withObject:[NSNumber numberWithInt:-1] afterDelay:4.0];

-(void) animate:(int) mode
{
[UIView animateWithDuration:0.2
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^{
                     self.center = CGPointMake(160.0, 568.0 + mode*height/2);
                 }
                 completion:nil];
}

Also, I cannot nest animations in completion: because it blocks UI interaction.

È stato utile?

Soluzione

I've tried your code and animation duration works great but I think you should fix the (int) mode part. You can't cast NSNumber to int that way. Your method must be - (void)animate:(NSNumber*)mode and after you can cast to int with [mode intValue].

Altri suggerimenti

You cannot use performSelector:withObject:afterDelay: with animate: because it has a parameter that is not object-pointer type.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top