我在这里浏览了一些关于MKPinAnnotationView引脚、子类等的链接,但不是全部。我在网上做了一些简单的教程,当我认为我可以用教程中的知识开始我的应用程序时,我错了。:(
在我的教程文件中,我设法做了一个简单的MKPinAnnotationView *引脚。设置其属性,如canShowCallOut = YES、draggable = YES。我可以将引脚拖到任何我想要的位置,并显示其放置的位置。
但是当我创建我的新应用程序时,我又做了同样的事情。但是大头针不动,是不是我做错了什么?
- (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;
}发布于 2011-11-09 23:45:59
瞧一瞧
http://digdog.tumblr.com/post/252784277/mapkit-annotation-drag-and-drop-with-callout-info
我也在寻找同样的问题。
https://stackoverflow.com/questions/7157777
复制相似问题