gpt4 book ai didi

ios - didUpdateToLocation 从未调用过

转载 作者:行者123 更新时间:2023-11-28 20:40:18 31 4
gpt4 key购买 nike

我正在使用模拟器和我的设备对此进行测试,但无论我做什么,都不会调用 didUpdateToLocation。我试过更改我在 sim 卡中的位置,关闭然后再次打开我手机上的定位服务以强制手机搜索新位置……什么都没有。在我的 viewDidLoad() 中,我已经启动了 CLLocationManager:

CLLocationManager *manager = [[CLLocationManager alloc] init];

if (![CLLocationManager locationServicesEnabled])
{
UIAlertView *servicesDisabledAlert = [[UIAlertView alloc] initWithTitle:@"Location Services Disabled" message:@"You currently have all location services for this device disabled. If you proceed, you will be asked to confirm whether location services should be reenabled." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[servicesDisabledAlert show];

} else {
manager.desiredAccuracy = kCLLocationAccuracyBest;

manager.delegate = self;

[manager startUpdatingLocation];


}

在更新位置方法中我有这个:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{

NSLog(@"NEW LOCATION! Accuracy:[%f]",newLocation.horizontalAccuracy);

}

有没有人知道为什么没有调用它?

最佳答案

您是否在头文件中添加了位置委托(delegate)?

关于ios - didUpdateToLocation 从未调用过,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8813480/

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