私は何時間も探し続け、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 と書かれています