2011-10-14 24 views
0

我在我的應用程序之前使用這一點,已經看着一切,我無法找到差異,但對當我運行一些原因:setAnimationDidStopSelector @selector沒有運行方法

-(void)moveSelectorToDisplayPosition:(id)sender{ 

    int givenTag = [sender tag]; 
    UIImageView *tempImageView = [displayedSelections objectAtIndex:givenTag]; 



    [UIView beginAnimations:@"" context:NULL]; 
    [UIView setAnimationDuration:.3]; 
    tempImageView.frame = CGRectOffset(tempImageView.frame, 30 - tempImageView.frame.origin.x, 240 - tempImageView.frame.origin.y); 
    [UIView setAnimationDidStopSelector:@selector(loadInTextForSelectedTool:)]; 
    [UIView commitAnimations]; 
} 

loadInTextForSelectedTool不會被調用和我無法弄清楚爲什麼。沒有錯誤或任何東西。

這是我試圖運行的方法,任何人都可以讓我知道,如果他們看到任何錯誤或者我可能已經忘記的東西?我試着也設置[UIView setAnimationDelegate:tempImageView];但沒有運氣:(。

-(void)loadInTextForSelectedTool:(id)sender;

感謝。

+0

但動畫運行正常嗎? –

+0

是的,它確實如此,所以我不知道問題是什麼... –

回答

4

您需要委託設置也實現loadInTextForSelectedTool:

[UIView setAnimationDelegate:self]; 

控制器,根據文件中,選擇器應該有以下形式:

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context 

最後,蘋果公司不鼓勵使用這種方法的動畫在iOS 4.0或更高版本:

這種方法的使用中的iOS 4.0及更高版本氣餒。您應該使用基於塊的動畫方法 來指定您的動畫。

+0

也許我對此有點困惑,但爲什麼我必須包含該方法?如果我只想在動畫完成時調用我自己的自定義方法?此外,我有我的代碼的確切工作副本,其他地方,我不做任何這些...任何想法,爲什麼這是工作? –

+0

好吧,它可能是這樣工作的,但是文檔聲明應該是選擇器的形式:「動畫結束後發送給動畫委託的消息。默認值爲NULL。選擇器的格式應該是: - ( void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context。「,http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView /UIView.html – Rengers

+0

我正在調查動畫塊。謝謝您的幫助。 –