多くのガレージがあり、マップに複数のガレージを表示する必要があります。
以下は、複数のピンを表示するためにマップに使用しているコードです。
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が表示されないように、このサブタイトルを非表示にしたい。
どうすればこれを行うことができますか?
- サブタイトルを非表示
また
- マップから GarageDetails に ID を渡します...