尝试为 a 添加一些注释MapView
,但不断遇到 ARC 语义问题:'没有可见的 @interface for 'MKPointAnnotation' 声明了选择器 initWithTitle:andCoordinate:
我对此很陌生,所以真的不知道这意味着什么,如果有人能解释/纠正它,我将不胜感激。
这是我的viewDidLoad
方法:
- (void)viewDidLoad
{
CLLocationCoordinate2D location;
location.latitude = (double) 51.501468;
location.longitude = (double) -0.141596;
MKPointAnnotation *newAnnotation = [[MKPointAnnotation alloc] initWithTitle:@"Buckingham Palace" andCoordinate:location];
[self._mapView addAnnotation:newAnnotation];
}
和我的头文件:
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface MapViewAnnotation : NSObject <MKAnnotation> {
NSString *title;
CLLocationCoordinate2D coordinate;
}
@property (nonatomic, copy) NSString *title;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d;
@end