iOS 8中CLLocationManager及MKMapView showUserLocation失败的解决办法
2014-10-07 11:41
507 查看
用XCode 6编译的原来XCode 5.1.1写的程序时,发现原来写的CLLocationManager定位的代码以及MKmapView的showUserLocation失效。查了一下,XCode 6选用iOS 8 SDK编译app的话,需要调用CLLocationManage 的requestAlwaysAuthorization 方法。
操作步骤如下:
1. 在AppDelegate的didFinishLaunchingWithOptions:方法中 [self.window makeKeyAndVisible]; 之后添加以下代码
2. 在 info.plist里加入:
NSLocationWhenInUseDescription,允许在前台获取GPS的描述
NSLocationAlwaysUsageDescription,允许在后台获取GPS的描述
完成。
参考:
http://www.cnblogs.com/tx8899/p/3989087.html http://blog.uniba.jp/post/91830563468/ios-8 http://www.cocoachina.com/bbs/read.php?tid-217107.html http://www.cocoachina.com/ask/questions/show/87714 http://9to5mac.com/2014/06/04/apple-improves-location-services-in-ios-8-with-when-in-use-mode-visit-monitoring/ http://derjohng.doitwell.tw/6197/%E9%9B%BB%E8%85%A6%E9%A1%9E%E5%88%A5/%E8%BB%9F%E9%AB%94%E7%AD%86%E8%A8%98/ios8-%E4%B8%8B%E5%AE%9A%E4%BD%8D-cllocationmanager-%E7%9A%84%E6%94%B9%E8%AE%8A/ http://www.cocoachina.com/ask/questions/show/113705/CLLocationManager%E8%8E%B7%E5%8F%96%E5%9C%B0%E5%9D%80%E5%81%8F%E5%B7%AE
操作步骤如下:
1. 在AppDelegate的didFinishLaunchingWithOptions:方法中 [self.window makeKeyAndVisible]; 之后添加以下代码
CLLocationManager *locationManager = [[CLLocationManager alloc] init]; // 判斷是否 iOS 8 if([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) { [locationManager requestAlwaysAuthorization]; // 永久授权 [locationManager requestWhenInUseAuthorization]; //使用中授权 } [locationManager startUpdatingLocation];
2. 在 info.plist里加入:
NSLocationWhenInUseDescription,允许在前台获取GPS的描述
NSLocationAlwaysUsageDescription,允许在后台获取GPS的描述
完成。
参考:
http://www.cnblogs.com/tx8899/p/3989087.html http://blog.uniba.jp/post/91830563468/ios-8 http://www.cocoachina.com/bbs/read.php?tid-217107.html http://www.cocoachina.com/ask/questions/show/87714 http://9to5mac.com/2014/06/04/apple-improves-location-services-in-ios-8-with-when-in-use-mode-visit-monitoring/ http://derjohng.doitwell.tw/6197/%E9%9B%BB%E8%85%A6%E9%A1%9E%E5%88%A5/%E8%BB%9F%E9%AB%94%E7%AD%86%E8%A8%98/ios8-%E4%B8%8B%E5%AE%9A%E4%BD%8D-cllocationmanager-%E7%9A%84%E6%94%B9%E8%AE%8A/ http://www.cocoachina.com/ask/questions/show/113705/CLLocationManager%E8%8E%B7%E5%8F%96%E5%9C%B0%E5%9D%80%E5%81%8F%E5%B7%AE
相关文章推荐
- iOS 8中CLLocationManager及MKMapView showUserLocation失败的解决办法
- iOS 8中CLLocationManager及MKMapView showUserLocation失败的解决的方法
- ios百度地图开发 BMKMapManager初始化crash问题解决办法
- 关于ios 程序加载百度地图lib,出现链接错误:找不到符号 (null): _OBJC_CLASS_$_BMKMapManager的解决办法
- CLLocation与mapkit(中国)的偏移处理办法add 修正偏差的处理另外办法,利用MKMapView *_mapView获取location消除误差;
- iOS Cllocationmanger定位, 使用Google Map API在mapview上画路径
- iOS 5.1.1越狱后恢复失败,以及升级ios6失败解决办法
- ios ipad 不调用 viewVillAppera 的解决办法
- Android中 View not attached to window manager错误的解决办法
- IOS LocationManager定位国内偏移,火星坐标(GCJ-02)解决方法
- MapView的OnTouchListener与setBuiltInZoomControls冲突导致无法触发OnTouch的解决办法
- IE浏览器执行 window.location.href 跳转失败的解决办法
- arcgis for server 登陆manager失败解决办法
- Android SDK Manager 加载sdk url失败(fetching refused) 解决办法
- Android SDK Manager 下载SDK失败的解决办法
- Android中 View not attached to window manager错误的解决办法
- ios 4.3 中 viewDidAppear没有被调用的解决办法
- [IOS地图开发系类]4、MKMapview上添加MKAnnotationView,标记当前位置
- iOS下CLLocationManager多次定位引起内存访问错误的问题解决