現在、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];
}
それをさらに操作するために何を変更する必要があるのか 正確にはわかりません。速度とすべてが完璧です。私はそれがばかげて回転することを望んでいません.