2011-09-19 44 views
2

我有一個問題想出如何使順序操作發生。動作序列(目標C)iPhone

分解爲最簡單的形式,我試圖做的是讓image1增長25%,只有在完成此操作後才能播放聲音。

我可以使圖像增長,我可以使聲音播放,沒問題,但我無法弄清楚如何使圖像增長25%後的聲音播放。

任何幫助將是偉大的。

謝謝。

+3

你是如何成長的形象呢?你能提供任何代碼嗎?你是否在爲圖像的增長提供動畫? – bryanmac

回答

1

您是否正在使用動畫來調整圖像/視圖的大小?如果是這樣你

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:1.0f]; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector:@selector(resizeFinished:finished:context:)]; 
// Resize the view/image here 
[UIView commitAnimations]; 

,然後在選擇,你可以播放聲音

- (void)resizeFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context; 
{ 
    // Play the sound here 
} 

您還可以實現回調委託

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag 
0

如果使用核心動畫,則可以在完成塊(iOS 4)中運行延續邏輯。或者您可以在setAnimationDidStopSelector上註冊回撥。詳情請看here