Created
September 10, 2014 15:09
-
-
Save ryanhanwu/80fbba02347d9d1853ec to your computer and use it in GitHub Desktop.
campass heading
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
There is no native compass UIView. In order to use the magnetometer, you'll have to use CoreLocation and the following delegate method: | |
- (void) locationManager:(CLLocationManager *)manager | |
didUpdateHeading:(CLHeading *)newHeading | |
to rotate a UIView to point North (bearingView is a UIImageView): | |
float heading = newHeading.magneticHeading; //in degrees | |
float headingDegrees = (heading*M_PI/180); //assuming needle points to top of iphone. convert to radians | |
self.bearingView.transform = CGAffineTransformMakeRotation(headingDegrees); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment