I have a small UIView that bounces in a drawer. I am adding Instant mode . Push. In fact, I add a lot of clicks - 5 or more Hz.
Mystery:
(1) Do I have removeBehavior ???? if so .. when ?!? "after" "instant"?
(2) Is it that UIPushBehaviorModeInstantaneous is a special case and you do not need (or cannot) delete these files?
(3) When you add Behavior: is it ... holding on ?! UIPushBehavior? Or?? WTF ?!
(4) It seems I could not find these aspects anywhere!
-(void)pushMeRight:(CGFloat)mag
{
if ( self.bounceAnimator == nil ) return;
NSLog(@"...........push me right %.2f", mag);
UIPushBehavior *pushRight = [[UIPushBehavior alloc]
initWithItems:@[self]
mode:UIPushBehaviorModeInstantaneous];
pushRight.magnitude = mag;
pushRight.angle = radians(0);
[self.bounceAnimator addBehavior:pushRight];
}
{. UIPushBehavior , . : " " , . , , .}
, Rob "" , .action, .
, , , "" , . :/
-(void)pushAllUp:(CGFloat)mag
{
if ( self.bounceAnimator == nil ) return;
for ( UIView *pushme in self.subviews )
{
UIPushBehavior *pp =
[[UIPushBehavior alloc]initWithItems:@[ pushme ]
mode:UIPushBehaviorModeInstantaneous];
pp.magnitude = mag;
pp.angle = radians(270);
UIPushBehavior __weak *weakPP = pp;
pp.action = ^{ if (!weakPP.active)
[self.bounceAnimator removeBehavior:weakPP];};
[self.bounceAnimator addBehavior:pp];
}
}