繁体   English   中英

如何在不使用委托的情况下获取当前位置?

[英]How to get current location without using delegate?

由于某些原因,我希望不使用委托方法来获取当前位置。
是否有一些解决方案可以仅从CLLocationManager获取当前位置?

您还可以使用CLLocationManager类的定位方法,该方法将返回设备的最后已知位置。

manager = [[CLLocationManager alloc] init]; [manager startUpdatingLocation]; CLLocation *location = [manager location];

检查以下链接,这些链接是使用Block进行位置更新的良好实现:

https://github.com/ideaismobile/AKLocationManager

https://github.com/axldyb/CLLocationManager-blocks

https://github.com/keithpitt/DKLocationManager

即使您可以使用NSNotificationCenter

检查一下: https : //stackoverflow.com/a/16173504/2919739

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM