3

我有一个简单的 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");
}];
4

1 回答 1

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.
}];
于 2012-11-15T15:40:55.450 回答