我在SO看過幾個與此相關的問題,但他們都沒有回答這個問題:delay
部分UIView
animateWithDuration:delay:options:animate:completion:
不會延遲。下面是調用它的實際代碼:UIView animateWithDuration:delay:options:animate:completion not undelaying
-(void) viewDidAppear:(BOOL)animated
{
NSLog(@"about to start animateWithDuration...");
[UIView animateWithDuration:3.0 delay:2.0 options:UIViewAnimationOptionTransitionNone
animations:^{NSLog(@"in the animations block..."); self.textView.hidden = YES;}
completion:^(BOOL finished){if (finished) {NSLog(@"In the completion block..."); self.textView.hidden = NO; [self.player play];}}];
}
這裏是NSLog
時間戳:
2013年6月18日15:27:16.607 AppTest1 [52083:C07]即將開始animateWithDuration。 ..
2013年6月18日15:27:16.608 AppTest1 [52083:C07]在動畫塊...
2013年6月18日15:27:16.609 AppTest1 [52083:C07在完成塊...
正如人們可以看到的那樣,指令的執行時間爲毫秒,而不是延遲2或3秒。有人會知道這個原因嗎?
感謝您的快速回復!我也通過不使用animateWithDuration完成了工作:完全可以使用[self performSelector:@selector(doneMethod)withObject:nil afterDelay:0.5]; – user2491253