2014-02-16 4 views
3

바로 지금, UIPanGestureRecognizer으로 사용자가 어디에서 건드린 지에 따라 화면에서 밀어내는보기에 사용하는 UIPushBehavior이 있습니다. 그것은 작동하지만 내 문제는보기가 어리석은 양을 돌리는 것입니다 ... 스포츠카의 타이어에 붙어있는 것처럼.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]; 
} 

나는 그것을 더 이상 조작 할 수 변경해야 정확히 알고하지 않습니다

이 내가 UIPushBehavior를 부착하는 방법입니다. 속도와 모든 것이 완벽합니다, 나는 단지 그것을 어리석게도 돌리고 싶지 않습니다.

답변

2

은 어쩌면 너무 늦었 어,하지만 당신은 완전히 회전을 제거하려면 다음을 수행하십시오

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

[self.animator addBehavior:self.pushBehavior];

+0

좋은 팁! 관련 .. http://stackoverflow.com/questions/25646857 – Fattie