Created
July 29, 2013 12:07
-
-
Save zapsleep/6103881 to your computer and use it in GitHub Desktop.
Transition of gyroscope data to contentOffset CGPoint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - Gyroscope to offset | |
- (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); | |
return newOffset; | |
} | |
- (void)displayLinkHandler { | |
[self setContentOffset:[self contentOffsetWithRotationRate:self.motionManager.deviceMotion.rotationRate]]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment