Здравствуйте, Каков наилучший способ получить местоположение на iPad, iPod, а также в iPhone.Местоположение показано 0.0 в iPad и iPod
Я включил следующее, но я все еще не могу получить правильное текущее местоположение. На IPOD я только получить место в первый раз:
+ (GPS*)get
{
if (!g_)
{
NSLog(@"Creating instance of GPS!");
g_ = [GPS new];
}
return g_;
}
@synthesize manager;
- (id)init
{
if (!(self = [super init]))
return nil;
//Setup the manager
manager = [[CLLocationManager alloc] init];
if (!manager)
{
return nil;
}
manager.distanceFilter = kCLDistanceFilterNone;
manager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
manager.desiredAccuracy = kCLLocationAccuracyBest;
manager.delegate = self;
if ([manager respondsToSelector:@selector(pausesLocationUpdatesAutomatically)])
{
manager.pausesLocationUpdatesAutomatically = NO;
}
if ([manager respondsToSelector:@selector(requestAlwaysAuthorization)])
{
[manager requestAlwaysAuthorization];
}
[manager startUpdatingLocation];
return self;
}
- (void)start
{
NSLog(@"Start Tracking");
[manager startUpdatingLocation];
}
-(void)stop
{
[manager stopUpdatingLocation];
}
#pragma mark CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *currentLocation = [locations lastObject];
NSLog(@"%f : %f", currentLocation.coordinate.latitude, currentLocation.coordinate.longitude);
//[self writeToFile];
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"locationManager - didFailWithError: %@", [error localizedDescription]);
NSLog(@"domain:%@", [error domain]);
//NSLog(@"code:%i", [error code]);
//[self writeToFile];
}
Какая версия iOS? – SanitLee
Я использую 8.4 на своем устройстве –