2012-11-15 59 views
3

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

更新:作为一个测试,我mangeled此方案及以下的非延迟动画瞬间发生,但如预期调度队列中的一个动画加班! 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

这可能不是解决你的问题,但随着iOS 4的苹果建议您使用的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. 
}]; 
发生:(
+0

同样的问题 - 我有原来,只是切换到“老在调试过程中 – 1dayitwillmake

+0

@ 1dayitwillmake你究竟在哪里放这段代码? –

+0

这个视图控制器的转换之后,在viewDidAppear函数 – 1dayitwillmake