我正在尝试编写一个iPhone应用程序,只需按一下按钮即可存储用户的初始位置。然后,他们可以稍后按下一个按钮,以显示他们的最终位置与其在MapView中的初始位置相关。我怎样才能做到这一点?谢谢!商店iPhone位置
0
A
回答
0
这是一个相当宽泛的问题。
有几件该任务:
- 获取位置。
- 将位置保存在某处。
- 检索位置。
首先,看看CLLocationManager。
对于第二个和第三个,最简单的选项可能是NSUserDefaults。
0
这里这是关于使用位置的迷你教程..
在这里.h文件中添加框架CoreLocation
第一组的代表像 并导入上的.h这行或者也.m文件添加这条线#import <CoreLocation/CoreLocation.h>
。
然后在.M走:
- (void)viewDidLoad {
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
CLLocationCoordinate2D here = newLocation.coordinate;
NSLog(@"%f %f ", here.latitude, here.longitude);
}
还当你想要然后存储在您按钮点击事件的位置,距离locationManager
这里locationManager
委托方法得到newLocation像上述方法-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
方法将得到每次核心位置都有话要对你说,这应该每隔几秒发生一次。这些CLLocation对象包含有关准确性的信息,因此您可以在该方法中筛选出好的点。 请务必在某个时间拨打[locationManager stopUpdatingLocation]
,然后拨打[locationManager release]
!
相关问题
- 1. X509Store位置与商店?
- 2. 商店小部件位置
- 3. 商店定位器API +地理位置
- 4. 根据商店位置搜索商店产品
- 5. CoreData中的商店位置(Swift)
- 6. Redis商店位置的用户策略
- 7. 拖放div和商店位置
- 8. 商店file_put_contents在安全的位置
- 9. 使用地理位置查找商店
- 10. 为iPhone创建JSON商店
- 11. 商店定位器与SQL
- 12. redis商店128位数
- 13. 商店岗位价值
- 14. 停用iOS和Android商店从商店,但使其复位的
- 15. 当商店发生变化时,React flux鼠标位置重置
- 16. Prestashop多商店设置
- 17. symfony2商店只读配置
- 18. ExtJS商店/网格重置
- 19. infinispan jdbc商店配置
- 20. Php商店小时 - 设置
- 21. CodeGear Delphi 2009商店设置
- 22. iphone应用商店重定向
- 23. Adobe AIR for iPhone应用商店?
- 24. 在iphone应用商店测验问题
- 25. 商店的Cookie在iPhone的localStorage
- 26. iPhone - 商店浮SQLite中通CoreData
- 27. iPhone商店远程服务器图像
- 28. 凡商店用户设置的iOS - 应用程序商店
- 29. 如何获得Drupal 8商店的商店设置
- 30. 使用opencart获取多商店设置的商店ID
欢迎来到Stack Overflow!请阅读常见问题解答,以便获得更高质量的问题答案。 请提供一些信息,确切地说你想要什么,到目前为止你已经尝试了什么,以及什么不工作。 – brainray