Hi,
I have a Tab-based iPhone Application. One tab is a UITableView + DetailView, the second is a MKMapView. In the MapView I have Callouts with buttons. Those buttons, I want to link to its DetailView at the first tab. How can I do that? The Detail View has its own Controller and xib file. My MKMapView Annotation code is following:
-(void)loadOurAnnotations
{
CLLocationCoordinate2D workingCoordinate;
dictionary = [[NSDictionary alloc] initWithContentsOfURL:[NSURL URLWithString: @"http://akm.madison.at/memorials.xml"]];
for(id key in dictionary) {
NSDictionary *tmp = [dictionary objectForKey:key];
NSString *name = [tmp objectForKey:@"name"];
NSString *type = [tmp objectForKey:@"type"];
NSNumber *coords_x = [tmp objectForKey:@"coords_x"];
NSNumber *coords_y = [tmp objectForKey:@"coords_y"];
workingCoordinate.latitude = [coords_x floatValue];
workingCoordinate.longitude = [coords_y floatValue];
/*Annotation *moons = [[Annotation alloc] initWithCoordinate:workingCoordinate];
[moons setTitle:name];
[moons setSubtitle:type];*/
Annotation *moons = [[Annotation alloc] initWithCoordinate:workingCoordinate];
//annotation.currentPoint = [NSNumber numberWithInt:1];
[moons setTitle:name];
//[mapView addAnnotation:annotation];
//[annotation release];
[map addAnnotation:moons];
NSLog(@"key=%@ value=%@", key, [dictionary objectForKey:key]);
}
}
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(Annotation *) annotation{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorGreen;
UIButton *myDetailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
myDetailButton.frame = CGRectMake(0, 0, 23, 23);
// Set the button as the callout view
annView.rightCalloutAccessoryView = myDetailButton;
annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
return annView;
}