美文网首页
IOS8地图定位相关

IOS8地图定位相关

作者: CyanCyan子衿 | 来源:发表于2016-03-09 09:06 被阅读57次

IOS8之后系统定位需要许可
在info.plist文件添加 NSLocationWhenInUseUsageDescription 和 NSLocationAlwaysUsageDescription。

代码添加定位请求
//必须定义全局变量,否则请求提示一闪即逝

  CLLocationManager  *locationManager;
  
  
  
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
    {
     locationManager = [[CLLocationManager alloc]init];
        if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
            [locationManager requestWhenInUseAuthorization];//iOS 8才有,且必须用上
        }
        
    }

相关文章

网友评论

      本文标题:IOS8地图定位相关

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