我一直在寻找好几个小时,试图获取并更新某些内容以便在iOS 5上使用drop和drag pin。我认为我非常接近...但是在尝试初始化自定义注释时存货。
这是我的班级
.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]];
THX
警告说setDraggable:selector是未知的......但不应该从
中删除答案 0 :(得分: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;
}