MapView 拖放引脚 - 自定义 MKAnnotationView iOS 5
我花了好几个小时寻找并更新一些可以在 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]
它所说的行上: Incompromedpointers types allocateing to 'AnnotationView * __strong' from 'MKPinAnnotationView *'
另外,下一行收到警告
[self performSelector:NSSelectorFromString(@"setDraggable:") withObject:[NSNumber numberWithBool:YES]];
Thx
警告说 setDraggable: 选择器未知..但不应该继承
I kept looking for hours, trying to get and update somehting to work on iOS 5 for a drop and drag pin. 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 *'
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)