4

I am trying to use the trash can animation in an iPhone application I am building. I know the feature I need help with is a private API but the app will be in-house.

According to the iPhoneDevWiki at the toolbar page you can activate the trash can opening animation using [UIToolbar animateToolbarItemIndex:duration:target:didFinishSelector:];.

After countless hours trying to use this method I could not get it to work. I have changed it so far to the following: [toolbar animateToolbarItemIndex:1 duration:1.0 target:self didFinishSelector:@selector(done:)];.

toolbar is the name of the UIToolbar I created programically using CGRectMake.

My button image for the trash can is 1, since it is the second button.

I have tried putting self and nil in target but it doesn't work.

didFinishSelector just links to -(void)done:(id)sender;.

If I change the animateToolbarItemIndex to something that does not exist, the console says that it does not exist. Any ideas to what I have wrong?

Botz3000
  • 39,020
  • 8
  • 103
  • 127
baharini
  • 217
  • 2
  • 11
  • animateToolbarItemIndex does not appear to be a part of the public API. Take a look at this answer: http://stackoverflow.com/questions/428110/how-can-i-replicate-the-trashing-animation-of-mail-app – mharper Apr 20 '11 at 21:55
  • 1
    Thanks. I am aware that it is a private API but I would like to use it in a in house app. I have got the suck animation working, but I needed help for the usage of the trash can animation. Could someone explain how it is used and a example? – baharini Apr 21 '11 at 06:27

1 Answers1

0

The trash can animation works with an array of images, each with the lid closing/opening a little more. So you'd do something like this:

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];

If you have a google I'm sure you'll be able to find the trash can images to use.

octermircty
  • 421
  • 5
  • 4