2011-02-23 63 views
2

我有一個非常奇怪的問題。在我開發的iOS應用程序中,在運行下面的動畫後,我發現UI的各種其他元素現在都會在出現時生成動畫。例如,一旦運行了以下這些動畫,每當我導航到我的應用程序中的新選項卡時,所有UI元素都會從iPhone左上角的動畫生成到適當的位置。我沒有在其他選項卡中爲這些UI元素指定動畫,實際上即使是我無法訪問的元素(例如iPhone狀態欄中的活動指示符),也會自行開始動畫。iOS:一個動畫之後,所有其他視圖開始動畫

這是怎麼回事?爲什麼只有在執行下面的動畫之後纔會發生這種情況?在運行此動畫之前(使用按鈕按下),其他應用程序選項卡中的所有其他UI元素在出現時都不會生成動畫,這是預期的行爲。

- (IBAction) btnChosenPostcodeClicked:(id)sender { 

    //prep animations 
    startView.alpha = 1.0; 
    postcodeView.alpha = 0.0; 

    [self.view addSubview:postcodeView]; 

    [UIView beginAnimations:@"ChosenPostcodeAnimation01" context:nil]; 

    [UIView setAnimationDuration:animationSpeed]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(chosenPostCodeFadeoutAnimationDone:finished:context:)]; 

    startView.alpha = 0.0; 

    [UIView commitAnimations]; 

} 

- (void)chosenPostCodeFadeoutAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { 
    //prep animations 
    postcodeView.alpha = 0.0; 

    [UIView beginAnimations:@"ChosenPostcodeAnimation02" context:nil]; 

    [UIView setAnimationDuration:animationSpeed]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES]; 

    CGRect newRect = CGRectMake(42, 157, 239, 180); 
    imvBubble.frame = newRect; 

    postcodeView.alpha = 1.0; 

} 

回答

3

你錯過了動畫的

[UIView commitAnimations]; 
在chosenPostCodeFadeoutAnimationDone

所以絕對你所做的一切正在成爲一部分!

+1

華!學校男孩錯誤。謝謝。 – Diego 2011-02-23 15:47:58

+0

用動畫包裹整個應用程序會很棒,你所做的一切都會變得動畫! HAHAH。 – Emil 2011-02-23 18:47:58

+0

順便說一句,除了動畫塊之外,還有其他可能的原因是因爲它發生在我身上,而我沒有一個未封閉的塊。 (iOS6的) – Ash 2013-08-05 09:57:45