I have created one application in which i want to display compass.but my application is showing me blank page..I have added CoreLocation framework also..Please help me to display compass.
.h file code:
import "UIKit/UIKit.h"
import "CoreLocation/CoreLocation.h"
@interface Compass_VIew : UIViewController<CLLocationManagerDelegate>
{
IBOutlet UIImageView *arrow;
IBOutlet UIImageView *arrowC;
CLLocationManager *locManager;
}
@property (nonatomic, retain) CLLocationManager *locManager;
@property(readonly, nonatomic) BOOL headingAvailable;
@end
.m file code
didUpdateHeading method code:
NSLog(@"New magnetic heading: %f", newHeading.magneticHeading);
NSLog(@"New true heading: %f", newHeading.trueHeading);
viewDidLoad method code:
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[[self navigationController] setNavigationBarHidden:NO animated:NO];
locManager = [[[CLLocationManager alloc] init] autorelease];
locManager.desiredAccuracy= kCLLocationAccuracyBest;
locManager.delegate = self;
[self.locManager startUpdatingHeading];
you need to give the transform for the needle of the compass
it should be like this
Here redPin is my needle view and by the way dont forget to import CoreLocation Framework