gpt4 book ai didi

iphone - MKMapView - 飞行模式开启时无法定位用户位置

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

我正在使用 MKMapView 类进行开发,当在设备 (iPhone5) 上运行并且 AirPlane 模式开启,Wi-Fi 开启时,

MKMapView的属性:showsUserLocation设置为YES,MKMapView的委托(delegate)

- (void)mapView:(MKMapView *)mapView didFailToLocateUserWithError:(NSError *)error

被调用,返回错误

Turn off airplane mode or use Wi-Fi to show your location on the map

告诉我关闭飞行模式或打开 Wi-Fi 以获取 map 上的位置。为什么我的飞行模式打开了,但我的Wi-Fi已启用,为什么我无法定位?

是MKMapView的bug,还是别的?谢谢!

最佳答案

The apple documentation says

Determining Whether Location Services Are Available

Every iOS-baseddevice is capable of supporting location services in some form butthere are still situations where location services may not beavailable:

The user can disable location services in the Settings app.

The usercan deny location services for a specific app.

The device might be inAirplane mode and unable to power up the necessary hardware. For thesereasons, it is recommended that you always call thelocationServicesEnabled class method of CLLocationManager beforeattempting to start either the standard or significant-change locationservices. (In iOS 3.x and earlier, check the value of thelocationServicesEnabled property instead.) If this class methodreturns YES, you can start location services as planned. If it returnsNO and you attempt to start location services anyway, the systemprompts the user to confirm whether location services should bereenabled. Given that location services are very likely to be disabledon purpose, the user might not welcome this prompt.

不,这不是错误,文档中明确说明了如何操作

关于iphone - MKMapView - 飞行模式开启时无法定位用户位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17188806/

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