[英]Trying to get CLLocationCoordinate2D Latitude and Longitude
您好,我试图在不显示地图的情况下获取用户所在位置的纬度和经度值,因此基本上它将在后台运行。 我想我必须使用地图套件,但是有示例吗?
如果您不想要地图,则不需要MapKit。 只需使用CLLocationManager即可 。
- (id) init {
if (self = [super init]) {
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager startUpdatingLocation];
}
return self;
}
- (void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)location fromLocation:(CLLocation *)oldLocation {
NSLog(@"lat:%f lon:%f", location.coordinate.latitude, location.coordinate.longitude);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.