Pregunta

Trato de hacer llegar la función locationServicesEnabled al trabajo ... pero mis espectáculos UIAlert arriba, no importa si los locationServices está habilitado o no! ¿Cómo consigo que esto funcione correctamente?

 @synthesize locationServicesEnabled
    -(void)viewDidLoad {
     [super viewDidLoad];

     if(![CLLocationManager locationServicesEnabled]) {
      self.locationManager = [[[CLLocationManager alloc] init] autorelease];
      locationManager.delegate = self;
      locationManager.desiredAccuracy = kCLLocationAccuracyBest;
      [locationManager startUpdatingLocation];
        } else {
            [[[[UIAlertView alloc] initWithTitle:@"Location services." 
                                         message:@"Location services are disabled." 
                                        delegate:nil 
                               cancelButtonTitle:@"OK" 
                               otherButtonTitles:nil] autorelease] show];       
        }
    }

Gracias de antemano!

¿Fue útil?

Solución

Looks like your condition is backwards. It currently says "if NOT location-services-enabled then start updating else alert".

Change the if to:

if([CLLocationManager locationServicesEnabled])

Remove the !.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top