Permalink
Browse files

Deal with orientation

  • Loading branch information...
drewmca
drewmca committed Feb 6, 2014
1 parent 4c9a860 commit e4621f7399406ba64c5a04304f5e03f16633e717
Showing with 9 additions and 3 deletions.
  1. +9 −3 DVParallaxView/DVParallaxView.m
@@ -159,11 +159,17 @@ -(void)addSubview:(UIView *)view {
- (CGPoint)contentOffsetWithRotationRate:(CMRotationRate)rotationRate {
double xOffset = (fabs(rotationRate.y) > DV_ROTATION_THRESHOLD)?rotationRate.y*DV_ROTATION_MULTIPLIER:0.f;
double yOffset = (fabs(rotationRate.x) > DV_ROTATION_THRESHOLD)?rotationRate.x*DV_ROTATION_MULTIPLIER:0.f;
- CGPoint newOffset = CGPointMake(self.contentOffset.x + xOffset,
- self.contentOffset.y + yOffset);
+ CGPoint newOffset;
+ if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation])){
+ newOffset = CGPointMake(self.contentOffset.x + yOffset, self.contentOffset.y + xOffset);
+ }
+ else{
+ newOffset = CGPointMake(self.contentOffset.x + xOffset, self.contentOffset.y + yOffset);
+ }
+
return newOffset;
}
-
+
- (void)displayLinkHandler {
[self setContentOffset:[self contentOffsetWithRotationRate:self.motionManager.deviceMotion.rotationRate]];
}

0 comments on commit e4621f7

Please sign in to comment.