0

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

1 に答える 1

0

見てみる

http://digdog.tumblr.com/post/252784277/mapkit-annotation-drag-and-drop-with-callout-info

私は同じ問題を探しています。

于 2011-11-09T15:45:58.563 に答える