- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation{
static int i=0;
if([self getCurrentLocation]==nil){
i++;
if(i>3){
[[self locationManager] stopUpdatingLocation];
useMyLocation = NO;
[self locationUpdated];
}
}else{
[self locationUpdated];
}
}
- (void)alertView:(UIAlertView *)anAlertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex==1){
self.useMyLocation = YES;
[[self locationManager] startUpdatingLocation];
}else{ // buttonIndex==0
self.useMyLocation = NO;
[self locationUpdated];
}
}
This is a working code in ios 4 and 5. My problem is that I can't get location to work in ios 6. The app doesn't even asks for permission from the user. After reading around this is what I've tried so far:
CFBundleDisplayName solution. I already had CFBundleDisplayName in my plist. I tried removing it and adding it again - no go.
setting the property pausesLocationUpdatesAutomatically of Location Manager to NO like this:
...
- (CLLocationManager *)locationManager{
if (locationManager != nil){
return locationManager;
}
CLLocationManager *tmp = [[CLLocationManager alloc] init];
tmp.pausesLocationUpdatesAutomatically = NO; //!@#
[self setLocationManager:tmp];
[tmp release];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager setDelegate:self];
return locationManager;
}
I also read about locationManager:didUpdateLocations:
, I didn't know how to implement it in the code, also i'm not sure if that's the solution.
Do you ever start the location manager?