Skip to content

Instantly share code, notes, and snippets.

@jmenter
Created February 20, 2017 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmenter/9797e4dc0952219d3f875fe2d77f3b1b to your computer and use it in GitHub Desktop.
Save jmenter/9797e4dc0952219d3f875fe2d77f3b1b to your computer and use it in GitHub Desktop.
Fake accelerometer data from iOS Simulator
- (CMAcceleration)platformSpecificAcceleration;
{
CMAcceleration acceleration = self.motionManager.accelerometerData.acceleration;
#if (TARGET_OS_SIMULATOR)
acceleration = (CMAcceleration){
UIDevice.currentDevice.orientation == UIDeviceOrientationLandscapeLeft ? -1.f :
UIDevice.currentDevice.orientation == UIDeviceOrientationLandscapeRight ? 1.f : 0.f,
UIDevice.currentDevice.orientation == UIDeviceOrientationPortrait ? -1.f :
UIDevice.currentDevice.orientation == UIDeviceOrientationPortraitUpsideDown ? 1.f : 0.f, 0.f};
#endif
return acceleration;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment