Simulator进行模拟定位
来源:互联网 发布:韩语网络教学 编辑:程序博客网 时间:2024/05/03 08:25
在项目中如果想要去进行定位服务,如果进行真机调试也不是很方便,我们可以利用simulator去模拟环游天朝了,具体步骤如下:
1.找到simulator的debug
2.然后修改经纬度
3.苹果提供了定位框架
#import <CoreLocation/CoreLocation.h>
一下是代码块:
- (void)locate{
//判断版本
self.locationManager = [[CLLocationManageralloc] init];
if ([[UIDevicecurrentDevice].systemVersiondoubleValue] >=8.0) {
[self.locationManagerrequestAlwaysAuthorization];
}
if ([CLLocationManagerlocationServicesEnabled]) {
//准确的经纬度
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
//精确的距离范围
self.locationManager.distanceFilter = 10;
self.locationManager.delegate = self;
}else{
UIAlertController *alertVc = [UIAlertControlleralertControllerWithTitle:@"提示"message:@"定位不成功"preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *sureAction = [UIAlertActionactionWithTitle:@"确定"style:UIAlertActionStyleDefaulthandler:nil];
[alertVc addAction:sureAction];
[selfpresentViewController:alertVcanimated:YEScompletion:nil];
}
//打开定位控制
[self.locationManagerstartUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
//locations 是获取到的一些地址
// NSLog(@"%@",locations);
CLLocation *currentLocation = [locationslastObject];
//反地址编码
CLGeocoder *geocoder = [[CLGeocoderalloc] init];
//通过经纬度确认城市位置
[geocoder reverseGeocodeLocation:currentLocationcompletionHandler:^(NSArray<CLPlacemark *> *_Nullable placemarks, NSError * _Nullable error) {
// NSLog(@"%@",placemarks);
if (placemarks.count >0) {
CLPlacemark *placeMark = [placemarksobjectAtIndex:0];
NSString *city = placeMark.locality;
if (!city) {
city = placeMark.administrativeArea;
}
if ([[citysubstringFromIndex:[citylength] - 1] isEqualToString:@"市"]) {
city = [city substringToIndex:[citylength] - 1];
}
self.cityLabel.text = city;
}
}];
}
- Simulator进行模拟定位
- Simulator 定位设置 TouchID/FaceID模拟
- 210 - Concurrency Simulator【模拟、双端队列】
- uva 210 Concurrency Simulator (并行堆栈模拟)
- UVA 210 Concurrency Simulator(deque,queue,模拟)
- UVA210 concurrency simulator (双向队列 & 模拟)
- simulator
- 使用selenium模块模拟浏览器爬去网页,并进行点击定位内容笔记
- UVa 210 - Concurrency Simulator(模拟+双端队列)
- iOS地图->模拟定位
- iOS模拟定位
- GPS定位模拟测试
- 三菱GX Developer+GX Simulator进行仿真调试
- 利用图片进行定位
- 怎样进行网站定位
- Network Delay Simulator模拟延时、带宽甚至丢包率,更精确地模拟慢网速环境
- android模拟器模拟定位GPS
- android模拟器模拟定位GPS
- cocos2dx学习之路----第七篇(坐标系统中本地坐标与世界坐标的转换详解)
- 长度为0数组
- NKOI 2753 区间连续值
- 关于特殊二维数组搜索
- 基于JavaScript的字符串暴力匹配算法(BF算法)
- Simulator进行模拟定位
- hdu 1598 极品飞车 (并查集+贪心)
- ecshop 站群,多模板,多域名共用一个后台
- goldengate 学习有用网址
- 字符串匹配 —— KMP 算法
- 使用HorizontalListView,实现左右滑动时,有箭头提示,到达端点时,箭头消失。
- Android利用canvas画各种图形
- 自定义动画实现splash页面3d旋转切换主页面
- 算法总结:判断一个数是否为素数