美文网首页
iOS开发设置定位提示框的解决方法

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

作者: 浪了里个浪 | 来源:发表于2018-01-15 17:01 被阅读0次

                      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查看是否设置了定位服务

    相关文章

      网友评论

          本文标题:iOS开发设置定位提示框的解决方法

          本文链接:https://www.haomeiwen.com/subject/xlddoxtx.html