- 1、本文档共11页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
《从零开始学iOS7开发系列3-我的地盘我做主-Cha11》.pdf
从零开始学iOS7开发系列3-我的地盘我做主-Cha11
原⽂及⽰例代码来⾃raywenderlich store中的iOS Apprentice 系列3教程,经过翻译和改编。
版权归原作者所有,本系列教程仅供学习参考使⽤,感兴趣的朋友建议购买原英⽂教程教程(The
iOS Apprentice Second Edition: Learn iPhone and iPad Programming via Tutorials!)。
购买链接:
/store
欢迎回来,在⽕炉边找个位置坐下来吧。
在上⼀课的内容中,我们接触了所谓的reverse geocoding这种神秘⽽⼜⾼⼤上的东⻄。
在实际测试的时候,可能在Simulator上会出⼀些状况,在iPod touch和⾮3G版的iPad上⾯也可能会
有问题。因为iPod touch和⾮3G版的iPad没有GPS ,只能靠Wi-Fi来定位。不过Wi-Fi的精度不够,
个⼈试过在+/-100⽶左右。
到现在为⽌,我们只能在位置信息精度进⼊desireAccuracy的范围内才能停⽌位置信息的更新,⽽
遗憾的是在iPod 上很难实现这⼀点。因此,在开发基于地理位置的应⽤时,我们必须在各种设备上
进⾏测试。
为了应对上⾯所说的情况,我们需要改善下didUpdateLocations⽅法。
在Xcode 中切换到CurrentLocationViewController.m ,更改didUpdateLocation⽅法如下:
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
CLLocation *newLocation = [locations lastObject];
NSLog(@ 已更新坐标,当前位置:%@,newLocation);
if([newLocation.timestamp timeIntervalSinceNow] -5.0){
return;
}
if(newLocation.horizontalAccuracy 0){
return;
}
CLLocationDistance distance = MAXFLOAT;
if(_location !=nil){
distance = [newLocation distanceFromLocation:_location];
}
if(_location == nil || _location.horizontalAccuracy newLocation.horizontalAccuracy){
_lastLocationError = nil;
_location = newLocation;
[self updateLabels];
if(newLocation.horizontalAccuracy = _locationManager.desiredAccuracy){
NSLog(@*** ⺫标诺森德!成功完成定位);
[self stopLocationManager];
[self configureGetButton];
}
if(distance 0){
_performingReverseGeocoding = NO;
}
if(!_performingReverseGeocoding){
NSLog(@*** Going to geocode);
_performingReverseGeocoding = YES;
[_geocoder reverseGeocodeLocation:_location completionHandler:^(NSArray
*placemarks,NSError *
您可能关注的文档
- 《不锈钢y型截止阀》.doc
- 《不锈钢圆弧齿轮油泵》.pdf
- 《不锈钢氨气减压阀》.doc
- 《不锈钢氨用截止阀》.doc
- 《不锈钢污水污物潜水泵》.pdf
- 《不锈钢潜水式排污泵》.pdf
- 《不锈钢调节球阀》.pdf
- 《不锈钢防爆齿轮油泵》.pdf
- 《不锈钢齿轮油泵》.pdf
- 《与罗伯特艾伦对话 创造多种收入流的秘密》.pdf
- 《中国通史》文字稿第12集春秋争霸.docx
- java教程--类与对象-讲义课件(演讲稿).ppt
- Vue应用程序开发-(1).pptx
- 东北师大版社劳动实践与评价指导手册一年级上册主题二活动一寻找五彩的树叶课时课件.pptx
- 外研版英语四年级上册 Module 4 Unit 2 How much is it单元教学设计.docx
- 外研版英语四年级上册Module 4 单元整体教学设计.docx
- 6《上课之前》课件 鄂科技版 心理健康教育一年级.pptx
- 《1~5的认识》说课课件(共25张PPT)人教版一年级上册数学.pptx
- 六《解决问题(1)》说课课件 人教版 三年级上册数学.pptx
- 七《解决问题》说课课件 人教版 二年级上册数学.pptx
文档评论(0)