iOS开发设置定位提示框的解决方法

                  iOS开发设置定位提示框的解决方法



1.首先查看你的info.plist里面是否添加Privacy - Location Always Usage Description,Privacy - Location When In Use Usage Description.

打开方式

2.在info.plist里面添加

<key>NSLocationWhenInUseUsageDescription</key>

<string>App需要您的同意,才能在使用期间访问位置</string>


info.plist添加

3.代码设置

#pragma mark 定位功能

- (void)locate {

    //判断定位功能是否打开

    if ([CLLocationManager locationServicesEnabled]) {

        locationManager = [[CLLocationManager alloc] init];

        locationManager.delegate = self;

        [locationManager requestAlwaysAuthorization];

        [locationManager startUpdatingLocation];

    }

}

4.大功告成.

定位提示框

5.如果没有出来的话试试清除下缓存或者在TARGETS--Info--Custom iOS Target Properties查看是否设置了定位服务

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容