CLLocationManager headerAvailable devuelve falso
Frecuentes
Visto 1,319 equipos
0
hola, estoy en una situación aquí, necesito ayuda sobre los datos de encabezado en ios, estoy haciendo un marco CoreLocation usado en mi aplicación
mi archivo .h
@interface ViewController : UIViewController<CLLocationManagerDelegate>{
UIImageView *arrowImage;
UILabel *magneticHeadingLabel;
UILabel *trueHeadingLabel;
CLLocationManager *locationManager;
}
@property (nonatomic, retain) CLLocationManager *locationManager;
@end
en archivo .m
@implementation ViewController
@synthesize locationManager;
-(void)locationManager:(CLLocationManager*)manager didUpdateHeading:(CLHeading*)newHeading {
NSLog(@"New magnetic heading: %f", newHeading.magneticHeading);
NSLog(@"New true heading: %f", newHeading.trueHeading);
NSLog(@"=>%@",[NSString stringWithFormat:@"%.1fmi",newHeading.headingAccuracy]);
NSString *headingstring = [[NSString alloc] initWithFormat:@"%f",newHeading.trueHeading];
trueHeadingLabel.text = headingstring;
[headingstring release];
NSString *magneticstring = [[NSString alloc]initWithFormat:@"%f",newHeading.magneticHeading];
magneticHeadingLabel.text = magneticstring;
[magneticstring release];
}
-(void)getHeadInfo{
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
self.locationManager.delegate = self;
if ([CLLocationManager headingAvailable] )
{
NSLog(@"Heading Available...!");
self.locationManager.headingFilter = kCLHeadingFilterNone;
[self.locationManager startUpdatingHeading];
}
else {
NSLog(@"No Heading Available: ");
UIAlertView *noCompassAlert = [[UIAlertView alloc] initWithTitle:@"No Compass!" message:@"This device does not have the ability to measure magnetic fields." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[noCompassAlert show];
[noCompassAlert release];
}
}
- (void)viewDidLoad {
[super viewDidLoad];
arrowImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"right_arrow"]];
arrowImage.frame = CGRectMake(95, 30, 128, 128);
[self.view addSubview:arrowImage];
trueHeadingLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 300, 250, 30)];
trueHeadingLabel.textAlignment = UITextAlignmentLeft;
trueHeadingLabel.textColor = [UIColor purpleColor];
trueHeadingLabel.backgroundColor = [UIColor clearColor];
trueHeadingLabel.font = [UIFont systemFontOfSize:13];
trueHeadingLabel.text = [NSString stringWithFormat:@"trueHeadingLabel:"];
[self.view addSubview:trueHeadingLabel];
magneticHeadingLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 350, 250, 30)];
magneticHeadingLabel.textAlignment = UITextAlignmentLeft;
magneticHeadingLabel.textColor = [UIColor purpleColor];
magneticHeadingLabel.backgroundColor = [UIColor clearColor];
magneticHeadingLabel.font = [UIFont systemFontOfSize:13];
magneticHeadingLabel.text = [NSString stringWithFormat:@"magneticHeadingLabel:"];
[self.view addSubview:magneticHeadingLabel];
UIButton *start = [[UIButton alloc]initWithFrame:CGRectMake(140, 310, 50, 30)];
[start setBackgroundColor:[UIColor redColor]];
[start setTitle:@"start" forState:UIControlStateNormal];
[start addTarget:self action:@selector(getHeadInfo) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:start];
[start release];
}
el caso es que sé que el simulador no devuelve los datos de rumbo, estoy usando un ipod touch, pero aún así [CLLocationManager headerAvailable] no devuelve verdadero. Esto es una especie de emergencia, por favor ayuda a alguien.
1 Respuestas
2
No estoy muy seguro, pero el iPod touch NO incluye un módulo GPS / brújula que yo sepa. Obtiene su información de ubicación a través de una base de datos wifi. Por lo tanto, no obtendrá un encabezado porque un iPod Touch no es capaz de dárselo.
Un iPod Touch tiene "sólo" un giroscopio y un acelerómetro disponibles. Para leer información sobre estos, debe utilizar el Marco de movimiento central
Un objeto CMMotionManager es la puerta de entrada a los servicios de movimiento proporcionados por iOS. Estos servicios proporcionan una aplicación con datos de acelerómetro, datos de velocidad de rotación, datos de magnetómetro y otros datos de movimiento del dispositivo, como la actitud. Estos tipos de datos se originan con los acelerómetros de un dispositivo y (en algunos modelos) su magnetómetro y giroscopio.
Respondido 02 Jul 12, 10:07
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas ios cllocationmanager or haz tu propia pregunta.
entonces, ¿cómo funciona la aplicación de brújula como ... itunes.apple.com/us/app/commander-compass-lite/id340268949?mt=8 - tempranodom