2012-07-13 124 views
0

我在UIView的touchesBegan方法內部有一些操作和動畫,這些操作和動畫在我的視圖中被分類並追加爲類。 我需要動畫之間的一些延遲。在UIView動畫之間添加延遲

代碼:

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    // Add delay to imitate the hold for touch 1 second and if true continue 
    // else cancel everything 

    [self animateViewSize]; // Here animates the view frame 

    // Add delay until sizing animation ends..... 

    [self animateViewFlip]; // Here animates the view flip y axis 

    [[NSNotificationCenter defaultCenter] postNotificationName:@"A Notification" object:self]; 
    // Notify the superview Controller that touch happened and do some operations with animations too... 

    // Some variables appending values for the UIView location when it touched 
} 

- (void) animateCardSize 
{ 
    // Animate using UIView animation 
} 
- (void) animateFlipView 
{ 
    // Animate flip using CABasicAnimation 
} 

這是基本的想法.....

謝謝。

回答

1

你也可以在你的方法

[self performSelector:@selector(animateCardSize) withObject:nil afterDelay:(2.0f)]; 
//2.0 and animateCardSize as examples 
2

您可以使用基於塊的UIView動畫這樣做:

[UIView animateWithDuration:0.4 animations:^{ 
    //Your first anim here 
} completion:^(BOOL finished){ 
    //Your second anim here 
}]; 
+0

感謝名單發表評論使用我有大小,所以我增加了一個基於塊的動畫完成代碼中的第二個翻轉動畫,解決了一個問題。在動畫開始之前和通知之前,我需要的觸摸延遲如何? – 2012-07-13 13:30:12