我在这里浏览了一些链接,而不是所有链接,关于MKPinAnnotationView
引脚、子类等。我在网上做了一些简单的教程,当我认为我可以利用教程中的知识开始我的应用程序时,我错了。:(
在我的教程文件中,我设法做了一个简单的 MKPinAnnotationView *pin。设置其属性,如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;
}