2011-04-20 98 views
4

我想在我正在建設的iPhone應用程序中使用垃圾桶動畫。我知道我需要幫助的功能是一個私人API,但該應用程序將是內部的。iPhone垃圾桶吸動畫

按照iPhoneDevWiki at the toolbar page可以激活垃圾桶使用[UIToolbar animateToolbarItemIndex:duration:target:didFinishSelector:];開場動畫。

無數個小時試圖用這種方法我無法得到它的工作之後。我已經將其更改爲以下內容:[toolbar animateToolbarItemIndex:1 duration:1.0 target:self didFinishSelector:@selector(done:)];

toolbar是我編程使用CGRectMake創建的UIToolbar的名稱。

我對垃圾桶按鈕圖像是1,因爲它是第二個按鈕。

我試過把selfnil放在target但它不起作用。

didFinishSelector只是鏈接到-(void)done:(id)sender;

如果我改變animateToolbarItemIndex的東西不存在,控制檯說,它不存在。任何想法,我有什麼錯?

+0

animateToolbarItemIndex並不似乎是公共API的一部分。看看這個答案:http://stackoverflow.com/questions/428110/how-can-i-replicate-the-trashing-animation-of-mail-app – mharper 2011-04-20 21:55:09

+1

謝謝。我知道這是一個私人API,但我想在一個內部應用程序中使用它。我已經有了吸引動畫的工作,但我需要使用垃圾桶動畫的幫助。有人可以解釋它是如何使用和一個例子嗎? – baharini 2011-04-21 06:27:05

回答

0

垃圾桶動畫與一系列圖像一起工作,每個蓋子關閉/打開多一點。所以,你會做這樣的事情:

UIImageView* trashCan = [[UIImageView alloc] initWithFrame:self.view.frame]; 
trashCan.animationImages = [NSArray arrayWithObjects:UIIMAGES, nil]; 
trashCan.animationDuration = 1.00; 
trashCan.animationRepeatCount = 1; 
[trashCan startAnimating]; 
[self.view addSubview:trashCan]; 

如果你有一個谷歌,我相信你肯定能找到垃圾桶的圖像使用。