gpt4 book ai didi

ios - CLLocationManagerDelegate 方法未更新

转载 作者:行者123 更新时间:2023-11-29 03:07:30 25 4
gpt4 key购买 nike

@property (nonatomic,strong) CLLocationManager *locManager;

这是我设置管理器的地方:

-(void) viewDidAppear:(BOOL)animated
{
self.locManager = [[CLLocationManager alloc] init];
[_locManager setDelegate:self];
[_locManager setDesiredAccuracy:kCLLocationAccuracyBest];
[_locManager setPausesLocationUpdatesAutomatically:NO];
[_locManager setDistanceFilter:1.0];
[_locManager startUpdatingLocation];
}

这是我的委托(delegate)方法:

- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
int degrees = newLocation.coordinate.latitude;
double decimal = fabs(newLocation.coordinate.latitude - degrees);
int minutes = decimal * 60;
double seconds = decimal * 3600 - minutes * 60;
NSString *lat = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
degrees, minutes, seconds];
latLabel.text = lat;
degrees = newLocation.coordinate.longitude;
decimal = fabs(newLocation.coordinate.longitude - degrees);
minutes = decimal * 60;
seconds = decimal * 3600 - minutes * 60;
NSString *longt = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
degrees, minutes, seconds];
lonLabel.text = longt;
}

该方法在启动时被调用三次,然后再也没有调用过。预先感谢您

最佳答案

上述方法已弃用。 请使用这个委托(delegate)

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation* location = [locations lastObject];

latitude = location.coordinate.latitude;
longitude = location.coordinate.longitude;

[locationManager stopUpdatingLocation];
locationManager = nil;
}

关于ios - CLLocationManagerDelegate 方法未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22602323/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com