简体   繁体   English

MapView拖放销-自定义MKAnnotationView iOS 5

[英]MapView Drop and Drag Pin - Custom MKAnnotationView iOS 5

I kept looking for hours, trying to get and update somehting to work on iOS 5 for a drop and drag pin. 我一直在寻找时间,试图获取和更新某些东西以便在iOS 5上进行拖放操作。 I think i'm pretty close... but stock when trying to init a custom annotation. 我认为我已经很接近了...但是尝试初始化自定义注释时存货。

Here's my class 这是我的课

.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

And the problem is on the line 问题就在网上

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

it says : Incompatible pointer types assigning to 'AnnotationView * __strong' from 'MKPinAnnotationView *' 它说:不兼容的指针类型从'MKPinAnnotationView *'分配给'AnnotationView * __strong'

Also, the next line is getting a warning to 另外,下一行正在警告

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

Thx 谢谢

The warning says that setDraggable: selector is unknow.. but shouldn't be herited from 警告说setDraggable:选择器是未知的..但不应从中继承

- (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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM