《从零开始学iOS7开发系列3-我的地盘我做主-Cha11》.pdf

《从零开始学iOS7开发系列3-我的地盘我做主-Cha11》.pdf

  1. 1、本文档共11页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 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 *

文档评论(0)

wgvi + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档