Solution How to Animate Garbage

I would like to place animation without documents in my program. Call method:

+ (void)animateToolbarItemIndex:(unsigned)index duration:(double)duration target:(id)target didFinishSelector:(SEL)selector; 

Can someone figure out what I should connect to:

  • index
  • Duration
  • target
  • Selector

My tests do not work, which leads to an error:

 2011-11-15 16:05:20.639 CNiPhone[973:707] +[UIToolbar animateToolbarItemIndex:duration:target:didFinishSelector:]: unrecognized selector sent to class 0x3f019c08 2011-11-15 16:05:20.641 CNiPhone[973:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIToolbar animateToolbarItemIndex:duration:target:didFinishSelector:]: unrecognized selector sent to class 0x3f019c08' 

Here is the relevant code:

 @interface UIToolbar (privateMethods2) + (void)animateToolbarItemIndex:(unsigned)index duration:(double)duration target:(id)target didFinishSelector:(SEL)selector; @end [UIToolbar animateToolbarItemIndex:0 duration:0.5 target:trashToolbarButton didFinishSelector:@selector(animateTrashStep2)]; [UIToolbar commitAnimations]; - (void) animateTrashStep2 { } 
+4
source share
6 answers

You do not need to do any undocumented material, just create a custom UIButton . Download the UIKit Artwork Extractor and you will find garbage animation frames, as well as the UIBarButtonItem background.

+3
source

You need to call it on the toolbar connected to your IBOutlet, unlike the class. For instance:.

 [self.myToolbar /*(possibly just myToolbar)*/ animateToolbarItemIndex:0 duration:0.5 target:trashToolbarButton didFinishSelector:@selector(animateTrashStep2)]; 
+3
source

You will probably find the answer here: fooobar.com/questions/1381387 / ...

+1
source

Your goal is probably set to trashButtonItem. The target is the object to which the didFinishSelector file will be sent. Try setting the goal for yourself. Also, according to http://iphonedevwiki.net/index.php/UIToolbar , this is not a class method, so you will need to replace [UIToolbar with the actual toolbar object.

In your didFinishSelector callback, I think you will call the method again and trashcan will close.

Good luck.

+1
source

This undocumented method is described here: http://iphonedevwiki.net/index.php/UIToolbar

It is documented as an instance method, not a class method that explains the error message you receive in the exception.

@ jrtc27 answered the question correctly, as this should be sent instead of the UIToolbar instance. From your response to the comments, it seems that you have not changed your class category to help the compiler. Instead, try the following:

 @interface UIToolbar (privateMethods2) - (void)animateToolbarItemIndex:(unsigned)index duration:(double)duration target:(id)target didFinishSelector:(SEL)selector; @end 

And then use:

 [self.navigationController.toolbar animateToolbarItemIndex:0 duration:0 target:self.trashToolbarButton didFinishSelector:@selector(animateTrashStep2)]; 
+1
source

I think if you know how to make suckEffect , you can do a bit of hacking with the toolbar.

Basically, all official controls are a subclass of UIView , so you can find out the hierarchy of the representation of an instance of UIToolBar.

If you do not know how to determine the hierarchy of the UIView given representation, you can use the PRIVATE API - (void)recursiveDescription from UIView . Remember to use it in your DEBUG configuration.

Why should we bother the hierarchy of views?

Answer: to hide a specific view or add a subview as we want.

What's next

  • Find the original UIBarButtonItem representation of your garbage.
  • Before running suckEffect, hide it, add new garbage to see what the open / close / shaking animation can do . At this point, I think you need to ask him to make the animation open .
  • Then let suckEffect fly ...
  • After suckEffect is complete, ask your view to close the animation.
  • After the close animation is complete, delete your view and view the original garbage.

Opportunity?

I have not done this before, but I think this is a possible solution, because garbage creation can be viewed using the open / close / shake animation.

Risk?

Anyway, this solution looks like some kind of hacking without touching the private api , a risk in itself.

Good luck.

+1
source

Source: https://habr.com/ru/post/1381386/


All Articles