我有,基于经度/纬度一系列代表物理分支对象的一个区域下降销一个MapView和注解视图对象属性。我已经得到了被提示打开共享应用程序映射给他们从他们的位置方向注释标注..但是,我无法弄清楚如何从分支对象/注释获取地址,当它传递在CalloutAccessoryControlTapped火灾:获得来自mapView.SelectedAnnotations
科对象:
CLLocationCoordinate2D newCord;
newCord.latitude = 34.0038;
newCord.longitude = -84.0965;
corp = [[LocationwithAnnotation alloc] initWithCoordinate:newCord];
corp.mTitle = @"Corp Office";
corp.mSubTitle = @"123 Main Street, Duluth GA";
[mapView addAnnotation:corp];
[corp release];
newCord.latitude = 33.0038;
newCord.longitude = -84.3965;
uga = [[LocationwithAnnotation alloc] initWithCoordinate:newCord];
uga.mTitle = @"uga Office";
uga.mSubTitle = @"123 Main Street, Atlanta GA";
[mapView addAnnotation:uga];
[corp release];
这些注释添加到地图,那么当标注被击中,我希望能够TP他们推到地图应用与所选择的注释的(CORP,例如)字幕。
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorGreen;
annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annView.calloutOffset = CGPointMake(-5, 5);
return annView;
}
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
NSLog(@"%@", mapView.selectedAnnotations);
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Directions"
message:@"Get directions to this branch?"
delegate:self
cancelButtonTitle:@"No"
otherButtonTitles: @"Yes, please", nil];
[alert show];
[alert release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
MKUserLocation *loc = mapView.userLocation.location;
double latitude = loc.location.coordinate.latitude;
NSString *lat = [NSString stringWithFormat:@"%f",latitude];
double longitude = loc.location.coordinate.longitude;
NSString *lon = [NSString stringWithFormat:@"%f",longitude];
NSString *base = @"http://maps.google.com/maps?";
NSString *dest = [@"daddr=" stringByAppendingString: mapView.SelectedAnnotations; // Doesn't work.
我的NSLog倾销的唯一的事情就是内存地址SelectedAnnotation ..我怎么能抓住从该对象?