Pregunta

I have created this little animation using UIDynamics - Push Behavior.

What I did was:

I created a simple UIPushBehavior like so:

self.pushBehavior = [[UIPushBehavior alloc] initWithItems:@[self.littleJumpy] mode:UIPushBehaviorModeInstantaneous];    

littleJumpy is just a UIView with size: {20, 20} that is added to the current view.

[animator addBehavior:self.pushBehavior];

Then afterward I would set the magnitude and then subsequently set active = YES;

The above is within a method.

It is working flawlessly.

At certain point in time I would set this push behavior's active state to NO. And afterward I would set it again to YES.

The problem arises with this. I realized that once a push behavior's active state is set to NO, it cannot be revived again by setting it to YES.

As a result, I would need to alloc and configure a new push behavior and add it to the animator all over again.

What worries me is memory issue, if we need to alloc and init the push behavior again and again after setting its active state to NO.

For a few animations, it shouldn't hurt, but if someone wanted to create a continuous movement and during the period the behavior's active state is set to NO and cannot simply be revived by setting it again to YES, in which case a new alloc + init needs to be performed again and then added to the animator over and over again.

Is this the normal behavior or am I missing something here?

Happy Holidays.

¿Fue útil?

Solución

This is an old question.

But after months of experimenting, I came to a conclusion that once the active state is set to NO, I would have to re-alloc and re-init the behavior again, in order to re-use the behavior.

Other words, setting it again to YES from NO does not re-activate the behavior.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top