UIViewAnimation立即播放,忽略延迟

时间:2012-11-15 15:35:59

标签: ios uiview uiviewanimation

我有一个简单的UIViewAnimation,一旦加载我的视图就会调用它。 但无论我将什么作为延迟值,它都会被忽略,动画会立即播放。

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:100.0];
[UIView setAnimationDelay:2.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(faceRight:finished:context:)];
_chooseLabelContainer.center = CGPointMake(originalCenter.x, 0 - _chooseLabelContainer.frame.size.height);
[UIView commitAnimations];

更新:作为测试,我已经管理了这个场景,并且在非延迟动画下面立即发生,但是调度队列中的那个按预期动画加班!     UIView * objectToAnimate = self.hudController-> _chooseLabelContainer;

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
    [UIView animateWithDuration:5.0 delay:2.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        NSLog(@"Start Dispatch %@", NSStringFromCGPoint( objectToAnimate.center ) );
        objectToAnimate.center = CGPointMake(objectToAnimate.center.x, objectToAnimate.center.y+90);
    }completion:^(BOOL done){
        NSLog(@"Done Dispatch");
    }];


});

[UIView animateWithDuration:5.0 delay:2.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
    NSLog(@"Start %@", NSStringFromCGPoint( objectToAnimate.center ) );
    objectToAnimate.center = CGPointMake( objectToAnimate.center.x, objectToAnimate.center.y+30);
}completion:^(BOOL done){
    NSLog(@"Done");
}];

1 个答案:

答案 0 :(得分:1)

这可能无法解决您的问题,但从iOS 4开始,Apple建议您使用UIView动画块:

[UIView animateWithDuration:100.0 delay:2.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
    _chooseLabelContainer.frame = CGPointMake(originalCenter.x, 0 - _chooseLabelContainer.frame.size.height);
}completion:^(BOOL done){
    [self faceRight:finished:context]; //will of course generate errors since I don't know what arguments to pass.
}];