ピン、サブクラスなどに関して、すべてではありませんが、ここでいくつかのリンクを確認しました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;
}