0

多くのガレージがあり、マップに複数のガレージを表示する必要があります。

以下は、複数のピンを表示するためにマップに使用しているコードです。

CLLocationCoordinate2D annotationCoord;
for (NSMutableDictionary* aDict in Gfeeds) {
    annotationCoord.latitude = [aDict[@"GLatitude"] floatValue];
    annotationCoord.longitude = [aDict[@"GLongitude"] floatValue];

    MKPointAnnotation *annotationPoint2 = [[MKPointAnnotation alloc] init];
    annotationPoint2.coordinate = annotationCoord;
    annotationPoint2.title = [NSString stringWithFormat:@"%@", aDict[@"GName"]];
    annotationPoint2.subtitle = aDict[@"GId"];

    [geomapView addAnnotation:annotationPoint2];

}

今私が欲しかったのは、そのマップピンをクリックした後にガレージの詳細を表示することです...そのために私は以下を行っています.

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{

    MKPinAnnotationView *pinAnnotation = nil;
    if(annotation != geomapView.userLocation)
    {
        static NSString *defaultPinID = @"myPin";
        pinAnnotation = (MKPinAnnotationView *)[geomapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
        if ( pinAnnotation == nil )
            pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];

        pinAnnotation.canShowCallout = YES;

        //instatiate a detail-disclosure button and set it to appear on right side of annotation
        UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        pinAnnotation.rightCalloutAccessoryView = infoButton;

    }

    return pinAnnotation;
}

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
    GarageDetailsViewController *secondView = [self.storyboard instantiateViewControllerWithIdentifier:@"GarageDetails"];

    secondView.garageMainId = view.annotation.subtitle;

    [self.navigationController pushViewController:secondView animated:YES];
}

この方法を使用して GarageDetails に移動できますが、サブタイトルにガレージの ID を表示するリスクがあります。Idが表示されないように、このサブタイトルを非表示にしたい。

どうすればこれを行うことができますか?

  1. サブタイトルを非表示

また

  1. マップから GarageDetails に ID を渡します...
4

1 に答える 1

1

" " をサブクラス化MKPointAnnotationし ( " " のような名前を付けることができますFahimPointAnnotation)、このサブクラスに " garageID" プロパティを追加できます。

次に、注釈をマップに追加し、クリックすると、注釈を取得して " MKPointAnnotation" を " " にキャストしFahimPointAnnotation、ガレージ ID を取得できます (注釈ビューのサブタイトルに表示されることを心配する必要はありません)。分野)。

于 2014-01-04T15:03:19.720 に答える