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: selector is unknown.. but should be herited from from と書かれています

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 に答える