现在,我有一个在视图上使用的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];
}我不知道我到底应该改变什么来更多地操纵它。速度和一切都是完美的,我只是不想让它旋转得如此荒谬。
发布于 2014-04-18 04:46:36
也许为时已晚,但如果您想完全消除旋转,请执行以下操作:
UIDynamicItemBehavior* dynamic = [[UIDynamicItemBehavior alloc] initWithItems:@[self.imageView]];
dynamic.allowsRotation = NO;
[self.animator addBehavior:dynamic];和[self.animator addBehavior:self.pushBehavior];
https://stackoverflow.com/questions/21807539
复制相似问题