How to make my view, which manipulates UIPushBehavior, not spin so much? This is an absurd amount.

Right now I have UIPushBehaviorone that I use in the view to bring it out of the screen depending on where the user is touched UIPanGestureRecognizer. It works, but my problem is that the view rotates the absurd amount ... how it is tied to the tire of a sports car.

Here is how I attach UIPushBehavior:

else if (panGestureRecognizer.state == UIGestureRecognizerStateEnded) {
    [self.animator removeBehavior:self.panAttachmentBehavior];

    self.pushBehavior = [[UIPushBehavior alloc] initWithItems:@[self.imageView] mode:UIPushBehaviorModeInstantaneous];
    [self.pushBehavior setTargetOffsetFromCenter:centerOffset forItem:self.imageView];
    self.pushBehavior.active = YES;

    CGPoint velocity = [panGestureRecognizer velocityInView:self.view];
    CGFloat area = CGRectGetWidth(self.imageView.bounds) * CGRectGetHeight(self.imageView.bounds);
    CGFloat UIKitNewtonScaling = 1000000.0;
    CGFloat scaling = area / UIKitNewtonScaling;
    CGVector pushDirection = CGVectorMake(velocity.x * scaling, velocity.y * scaling);

    self.pushBehavior.pushDirection = pushDirection;

    [self.animator addBehavior:self.pushBehavior];
}

I do not know exactly what I have to change in order to manipulate it more. The speed and everything is perfect, I just do not want it to spin as absurdly.

+3
source share
1 answer

, , , :

UIDynamicItemBehavior* dynamic = [[UIDynamicItemBehavior alloc] initWithItems:@[self.imageView]];
dynamic.allowsRotation = NO;
[self.animator addBehavior:dynamic];

[self.animator addBehavior:self.pushBehavior];

+2

All Articles