몇 가지 예를 살펴 보았지만 정확하게 구현하는 방법이 확실하지 않습니다 (예 : iPhone Compass GPS Direction). (void) 시작시 calcBearingWithLatitude를 호출해야합니까? ?나침반을 사용하여 북쪽 대신 실제 좌표 위치를 가리 키십시오.
내가하고자하는 모든 것은 나침반이 메모리에서 포인트를 가져 와서 그 포인트를 "북쪽"으로 사용하여 말하거나 포인트하거나 거리 또는 다른 것을 필요로하지 않는 것입니다. B.
을 B를 조정하는 좌표와 좌표에서 다음 조정 나침반 베어링에 대한 오프셋으로 그 베어링을 사용에서 나는 베어링을 찾을 것@implementation TrackerViewController
@synthesize locationManager;
@synthesize compass;
@synthesize headingLabel;
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if ([CLLocationManager headingAvailable]) {
} else {
[[[[UIAlertView alloc] initWithTitle:@"Error"
message:@"Device doesn't support heading updates"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] autorelease] show];
}
}
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {
double heading = [newHeading magneticHeading] * M_PI/180.0;
self.compass.transform = CGAffineTransformMakeRotation(-heading);
self.headingLabel.text = [NSString stringWithFormat:@"%d°", (int)[newHeading magneticHeading]];
NSLog(@"%d", (int)[newHeading magneticHeading]);
}
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error {
// NSLog(@"Error!");
if (error.code == kCLErrorDenied) {
[[[[UIAlertView alloc] initWithTitle:@"Error"
message:@"User didn't allow heading updates"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] autorelease] show];
[self.locationManager stopUpdatingHeading];
}
}
- (void)viewDidLoad {
locationManager=[[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.delegate=self;
//Start the compass updates.
[locationManager startUpdatingHeading];
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)dealloc {
self.locationManager = nil;
self.compass = nil;
self.headingLabel = nil;
[super dealloc];
}
@end
나침반에 대한 맞춤 표제를 만들 수 있습니까? –