shows user location在iOS8上不能使用地图定位
2015-01-12 13:41
316 查看
在xcode6中 苹果地图得定位方法修改了,以前得不能用了
报错说明:Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.
解决办法:
在Supporting Files下得XXX.info.plis里面添加NSLocationAlwaysUsageDescription 或 NSLocationWhenInUseDescription 两个String字段,value可以为空,也可以设置YES,不过我得问题还是不能解决,最终还是找到得了问题所在,就是info.plist中还需要包含Supported
interface orientations 这个Array字段。然后运行就解决了.
代码处理:
另外一处:
上面那行是 iOS 8 以上,第二行是 iOS 7 以下, kCLAuthorizationStatusAuthorized 在 iOS 8 完全不能使用。
別的地方:
报错说明:Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.
解决办法:
在Supporting Files下得XXX.info.plis里面添加NSLocationAlwaysUsageDescription 或 NSLocationWhenInUseDescription 两个String字段,value可以为空,也可以设置YES,不过我得问题还是不能解决,最终还是找到得了问题所在,就是info.plist中还需要包含Supported
interface orientations 这个Array字段。然后运行就解决了.
代码处理:
locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy=kCLLocationAccuracyBest; if([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { [locationManager requestWhenInUseAuthorization]; } [locationManager startUpdatingLocation];
另外一处:
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { if ( ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)] && status != kCLAuthorizationStatusNotDetermined && status != kCLAuthorizationStatusAuthorizedWhenInUse) || (![locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)] && status != kCLAuthorizationStatusNotDetermined && status != kCLAuthorizationStatusAuthorized) ) { NSString *message = @"您的手机目前未开启定位服务,如欲开启定位服务,请至设定开启定位服务功能"; UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"无法定位" message:message delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil]; [alertView show]; }else { [locationManager startUpdatingLocation]; } }
上面那行是 iOS 8 以上,第二行是 iOS 7 以下, kCLAuthorizationStatusAuthorized 在 iOS 8 完全不能使用。
別的地方:
CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; if (status == kCLAuthorizationStatusAuthorizedWhenInUse || status == kCLAuthorizationStatusAuthorized) { // 开始定位 }else { // 提示警告 }
代码修改片段来源于此:http://blog.dreambreakerx.com/tag/ios/
相关文章推荐
- shows user location在iOS8上不能使用地图定位
- map的showsUserLocation和mkAnnotation混合使用注意事项,防止crash
- 在用MKMapView self.mapView.showsUserLocation = YES; 实现定位时不能打开飞行模式
- ireport $P{SUBREPORT_DIR}参数的使用 解决:Could not load object from location 不能加载子报表问题
- Can't User UserProfileManager.GetUserProfile Get User Userprofile In Web Service,Error:System.ArgumentNullException: Value Cannot Be Null.(不能在Webservice中使用UserProfileManager的GetUserProfile得到用户配置,报错:System.ArgumentNullException: 值不能为空。)
- user版本不能使用adb问题
- iOS CoreLocation框架第一章—— CLLocationManager的使用(包含iOS6,iOS8,iOS9各种变动)
- mac的终端下面使用ssh user@localhost输入密码 不能正常登录
- 使用jstl,session.setAttribute不能设置名称为“userinfo”,否则获取不到
- iOS8 CLLocationManager 的改变导致 locationManager didUpdateLocations不能被调用的解决办法
- 紧急求救。sql中使用user关键字做表名,怎么解决啊!(做二次开发,表名不能换啊!)
- [Phonegap+Sencha Touch] 移动开发39 某些安卓手机的webview使用location.href="tel:123456"不能调到打电话的界面
- mac的终端下面使用ssh user@localhost输入密码 不能正常登录
- iOS8之后CoreLocation定位的使用
- ios8下LocationManager及Nsnotification使用
- MKMapView.showsUserLocation 可能触发了 UIView.setNeedsLayout
- mysql gui tools图形操作界面不能使用 改下mysqlx_user_connections.xml就好了
- Unity3d的Input.location在ios8以上版本不能正常工作的解决方案
- iOS CoreLocation使用(iOS8 回调不行的问题解决)
- 使用HttpContext的User属性来实现用户验证