sdk8.0以后,GPS定位的问题
来源:互联网 发布:linux bind 配置 编辑:程序博客网 时间:2024/05/20 20:57
1. 在 info.plist里加入对应的缺省字段 ,值设置为YES(前台定位写上边字段,前后台定位写下边字段)
NSLocationWhenInUseUsageDescription //允许在前台获取GPS的描述
[locationManager requestWhenInUseAuthorization];// 前台定位
NSLocationWhenInUseUsageDescription //允许在前台获取GPS的描述
NSLocationAlwaysUsageDescription //允许在前、后台获取GPS的描述
2. 调用请求:
//设置定位权限 仅ios8有意义[locationManager requestWhenInUseAuthorization];// 前台定位
[locationManager requestAlwaysAuthorization];// 前后台同时定位
3. 添加坐标点:Product->Scheme->EditScheme
Options->Default Location->(选择一个地点)
4.添加Framework
MapKit.framework
CoreLocation.framework
代码片段
-(IBAction)StartGPS:(id)sender{ if (self.locationManager == nil) { self.locationManager = [[CLLocationManager alloc] init];// [self.locationManager requestAlwaysAuthorization];//前台和后台都要进行定位 [self.locationManager requestWhenInUseAuthorization];//只有在前台的时候才进行定位 } self.locationManager.delegate = self; [self.locationManager startUpdatingLocation];}- (IBAction)StopGPS:(id)sender{ [self.locationManager stopUpdatingLocation];}#pragma mark - CLLocationDelegate- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ CLLocation *location = [locations objectAtIndex:0]; [self.mapView setCenterCoordinate:location.coordinate animated:YES]; //定义显示的范围 MKCoordinateSpan theSpan; theSpan.latitudeDelta=0.1; theSpan.longitudeDelta=0.1; //定义一个区域(用定义的经纬度和范围来定义) MKCoordinateRegion theRegion; theRegion.center=location.coordinate; theRegion.span=theSpan; [self.mapView setRegion:theRegion animated:YES];}
0 0
- sdk8.0以后,GPS定位的问题
- android上的GPS定位的问题
- android上的GPS定位的问题
- GPS的定位原理
- Android的GPS定位
- Android的gps定位
- Android的GPS定位
- android4.3 GPS定位问题
- IOS SDK8.0 FaceBook pop动画类库报错问题
- GPS定位不准确、有偏差的问题
- GPS定位不准确、有偏差的问题
- GPS定位信息的接收
- GPS定位信息的接收
- GPS定位信息的接收
- Android GPS 定位的实现
- Android GPS 定位的实现
- Android GPS 定位的实现
- Android GPS 定位的实现
- tcp流与tcp会话
- 最小生成树(MST)----普里姆(Prim)算法与克鲁斯卡尔(Kruskal)算法
- Api development and mobile end development start concurrently
- 社説 20150310 日独首脳会談 紛争解決へ「法の支配」強めよ
- 02-Wooyoo游戏开发之了解工具环境
- sdk8.0以后,GPS定位的问题
- 最近要复制一个php的产品成java,简单记录一下php的知识
- 最近开始研究openpilot的开源飞控,记录一下
- yuv和yCbCr的差异
- Knockout 速率限制可观察通知(Rate-limiting observable notifications)
- tomcat在centos下面的安装
- Split Bregman算法用于CS问题的个人理解
- Android SlidingMenu 使用详解
- iOS键盘遮挡解决方案