MKPinAnnotationView 不动
我在这里浏览了一些链接,但不是全部,关于 MKPinAnnotationView 引脚、子类等。我在网上做了一些简单的教程,当我认为我可以用来自教程,我错了。 :(
在我的教程文件中,我设法做了一个简单的 MKPinAnnotationView *pin。设置其属性,例如 canShowCallOut = YES
、draggable = YES
。我可以将 pin 拖动到任何地方我想显示它掉落的位置,
但是当我创建新应用程序时,我又做了同样的事情,但是图钉没有移动,我做错了什么吗?
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
if([annotation isKindOfClass:[CustomPlacemark class]])
{
MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:[annotation title]];
newAnnotation.pinColor = MKPinAnnotationColorGreen;
newAnnotation.animatesDrop = YES;
newAnnotation.canShowCallout = YES; // shows the black label when the pin is tapped
newAnnotation.draggable = YES;
// newAnnotation.enabled = YES;
newAnnotation.tag = tag;
NSLog(@"%@ %@", [annotation title], [annotation subtitle]);
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
newAnnotation.rightCalloutAccessoryView = rightButton;
NSLog(@"Created annotation at: %f %f", ((CustomPlacemark*)annotation).coordinate.latitude, ((CustomPlacemark*)annotation).coordinate.longitude);
[newAnnotation addObserver:self
forKeyPath:@"selected"
options:NSKeyValueObservingOptionNew
context:@"GMAP_ANNOTATION_SELECTED"];
[newAnnotation autorelease];
tag++;
NSLog(@"ååååååååå %@", appDelegate.fml);
return newAnnotation;
}
return nil;
}
I have went through a few links here, not all of them, regarding MKPinAnnotationView
pin, subclass, etc. I did some simple tutorials online and when I thought I could start on my application with the knowledge from the tutorials, I was wrong. :(
In my tutorial file, I managed to do a simple MKPinAnnotationView *pin. Set its properties, like canShowCallOut = YES
, draggable = YES
. I can drag the pin anywhere I want to and display the location its dropped at.
But when I created my new application, I did the same thing again. But the pin isn't moving, is there something I did wrong?
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
if([annotation isKindOfClass:[CustomPlacemark class]])
{
MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:[annotation title]];
newAnnotation.pinColor = MKPinAnnotationColorGreen;
newAnnotation.animatesDrop = YES;
newAnnotation.canShowCallout = YES; // shows the black label when the pin is tapped
newAnnotation.draggable = YES;
// newAnnotation.enabled = YES;
newAnnotation.tag = tag;
NSLog(@"%@ %@", [annotation title], [annotation subtitle]);
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
newAnnotation.rightCalloutAccessoryView = rightButton;
NSLog(@"Created annotation at: %f %f", ((CustomPlacemark*)annotation).coordinate.latitude, ((CustomPlacemark*)annotation).coordinate.longitude);
[newAnnotation addObserver:self
forKeyPath:@"selected"
options:NSKeyValueObservingOptionNew
context:@"GMAP_ANNOTATION_SELECTED"];
[newAnnotation autorelease];
tag++;
NSLog(@"ååååååååå %@", appDelegate.fml);
return newAnnotation;
}
return nil;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看
http://digdog。 tumblr.com/post/252784277/mapkit-annotation-drag-and-drop-with-callout-info
我正在寻找同样的问题。
Take a look
http://digdog.tumblr.com/post/252784277/mapkit-annotation-drag-and-drop-with-callout-info
I'm looking for the same problem.