3

现在,我有一个UIPushBehavior我在视图上使用的,根据用户用UIPanGestureRecognizer. 它有效,但我的问题是视图旋转了一个荒谬的量......就像它连接到跑车的轮胎一样。

这就是我附加的方式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];
}

我不知道我应该改变什么来更多地操纵它。速度和一切都很完美,我只是不想让它旋转得那么荒谬。

4

1 回答 1

2

也许为时已晚,但如果您想完全消除轮换,请执行以下操作:

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

[self.animator addBehavior:self.pushBehavior];

于 2014-04-17T20:46:36.213 回答