IOS8地图定位相关

2016-03-09  本文已影响57人  CyanCyan子衿

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才有,且必须用上
        }
        
    }
上一篇 下一篇

猜你喜欢

热点阅读