我想在我的应用程序中嵌入指南针可以任何人帮助我PLZ
- (void)viewDidLoad {
locationManager=[[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.delegate=self;
//Start the compass updates.
//[self.locationManager startUpdatingHeading];
[[self locationManager] startUpdatingHeading];
[super viewDidLoad];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
NSLog(@"New magnetic heading: %f", newHeading.magneticHeading);
NSLog(@"New true heading: %f", newHeading.trueHeading);
}
此代码无法在设备上运行,它只在模拟器上运行???任何想法???