【发布时间】:2011-10-19 18:45:52
【问题描述】:
我一直在寻找几个小时,试图获取和更新一些在 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: 选择器是未知的.. 但不应继承
【问题讨论】:
标签: iphone mkmapview ios5 mkannotationview mkpinannotationview