ios - 在 CLLocationManager 类型的对象上找不到属性坐标

标签 ios objective-c mapkit core-location

我正在构建一个跟踪用户位置的小型应用程序,将他们的位置数据存储在一个数组中,并在 MKOverlay 中绘制折线。

我认为我已正确设置所有内容,但我收到上述错误:在 CLLocationManager 类型的对象上找不到属性坐标

ViewController.h

#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>

@interface ViewController : UIViewController <CLLocationManagerDelegate, MKMapViewDelegate, MKOverlay> {

CLLocationManager *locationManager;
NSMutableArray *trackingPointArray;

MKMapRect routeRect;
MKPolylineView *routeLineView;
MKPolyline *routeLine;

}

- (IBAction)startFollowing:(id)sender;
- (IBAction)stopFollowing:(id)sender;

@property (nonatomic, weak) IBOutlet MKMapView *mapView;

@end

问题代码

    CLLocationDegrees Latitude = currentLocation.coordinate.latitude;
    CLLocationDegrees Longitude = currentLocation.coordinate.longitude;
    CLLocationCoordinate2D locationCoordinates = CLLocationCoordinate2DMake(Latitude, Longitude);

我想这可能是因为我没有在我的 .h 上声明对象,但是当我添加

@property (nonatomic, weak) CLLocation *coordinate; 

我收到一个新错误:属性类型 CLLocation 与继承自 MKOverlay 的类型 CLLocationCoordinate2D 不兼容

从我所看到的一切来看,这应该是可行的,但当然就目前而言,它无法构建。将不胜感激朝着正确的方向前进。

最佳答案

答案就在眼前

再往上我有:

CLLocationManager *currentLocation = [locations lastObject];

错错错!!!

我应该有:

CLLocation *currentLocation = [locations lastObject];

关于ios - 在 CLLocationManager 类型的对象上找不到属性坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31041017/

相关文章:

ios - 如何使用 Swift 将图像上传到 iOS 中的服务器?

ios - 将最大宽度设置为约束

ios - FBUserSettingsViewController 在关闭时崩溃

iphone - 关闭/呈现模态视图 Controller - viewdidLoad 再次调用

swift - 在 swift 上显示用户位置

swift - 如何在 Swift 中创建带有边框和阴影的圆形图像作为 MKAnnotationView?

iphone - 如何从 Xcode 获取 ipa 文件以在真实设备中运行 iPhone 应用程序?

objective-c - ModalViewController 没有调光/禁用当前 View Controller

ios - 在 Objective-C 中播放背景音乐

objective-c - ios6 mapkit错误模拟器