gpt4 book ai didi

ios - Xcode 6 GM - CLLocationManager

转载 作者:可可西里 更新时间:2023-11-01 17:17:27 25 4
gpt4 key购买 nike

我有一个使用 Xcode 5 制作的项目。我有一个 ViewController,我在其中使用 CLLocationManager 获取电话位置。我已经实现了:

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error

效果很好。

现在我用 Xcode 6 GM 打开项目,这两种方法都没有被调用(不是在模拟器或设备上)。

有什么想法吗?谢谢

最佳答案

请检查线程 here

你必须注意两件事

1.

  • requestAlwaysAuthorization - 用于后台定位

    [self.locationManager requestWhenInUseAuthorization];

  • requestWhenInUseAuthorization-仅在应用处于事件状态时定位

    [self.locationManager requestAlwaysAuthorization];

如果您没有发出两个请求中的任何一个,iOS 将忽略 startUpdateLocation 请求。

2。根据您请求的权限,在 Info.plist 中包含 NSLocationAlwaysUsageDescriptionNSLocationWhenInUseUsageDescription 键。此字符串将由 iOS 显示给用户,以便用户可以清楚地知道为什么我们的应用程序需要权限。

希望这对您有所帮助。

关于ios - Xcode 6 GM - CLLocationManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25844430/

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