[英]How to get Current Location using SwiftUI, without ViewControllers?
[英]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
,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.