2011-04-20 35 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]; 

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