0

我一直在寻找几个小时,试图获取和更新一些在 iOS 5 上工作的拖放图钉。我想我已经很接近了……但是在尝试初始化自定义注释时存货。

这是我的课

.h
@interface AnnotationView : MKAnnotationView ...

.m
@interface AnnotationView () 
@property (nonatomic, assign) BOOL hasBuiltInDraggingSupport;
@end

@implementation AnnotationView
@synthesize hasBuiltInDraggingSupport, mapView;


- (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier {

self.hasBuiltInDraggingSupport = [[MKAnnotationView class] instancesRespondToSelector:NSSelectorFromString(@"isDraggable")];

if (self.hasBuiltInDraggingSupport) {
    if ((self = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseIdentifier])) {
        [self performSelector:NSSelectorFromString(@"setDraggable:") withObject:[NSNumber numberWithBool:YES]];
    }
}

self.canShowCallout = YES;
return self;
}
@end

而问题就出在这条线上

self = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]

它说:从'MKPinAnnotationView *'分配给'AnnotationView * __strong'的不兼容指针类型

此外,下一行正在收到警告

[self performSelector:NSSelectorFromString(@"setDraggable:") withObject:[NSNumber numberWithBool:YES]];

谢谢

警告说 setDraggable: 选择器是未知的.. 但不应该继承自

4

1 回答 1

1
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id<MKAnnotation>)annotation
{
    MKPinAnnotationView* annView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"xxx"];
    // check conditions for class of annview or other    
    annView.draggable = YES;
}
于 2011-11-10T22:19:15.413 回答