If I understand correctly, you want to add a disclosure button that will allow you to submit a new view with information about the current output annotation. To get the disclosure button, you just need to implement this code:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { MKPinAnnotationView *pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"pinView"]; if (!pinView) { pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pinView"] autorelease]; pinView.pinColor = MKPinAnnotationColorRed; pinView.animatesDrop = YES; pinView.canShowCallout = YES; UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; pinView.rightCalloutAccessoryView = rightButton; } else { pinView.annotation = annotation; } return pinView; }
Now, when you click on the contact on mapView, the disclosure button will be displayed on the presented view. Then you will need to use the following method to tell the application what to do when the expand button is clicked.
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
In this method, you can present a popover or modal window, or click a view or what you would like to do with information about the current location. You also do not need to create a new tip for each of them. The easiest way would be to synthesize the values ββin this kind of controller such as phoneNumber and website , and the like. Then in the last method where you present the view, pass the values ββas needed. For instance,
NewView *vc = [[NewView alloc] initWithNibName:@"NewView" bundle:nil]; vc.phoneNumber =
etc. before submitting a presentation. Hope this helps
EDIT: To get rid of this error, for everything you synthesize, you must declare in the header. So you will have
@interface FirstViewController : UIViewController { IBOutlet MKMapView *mapView;
You will also need this in the annotation header if you use it. He reports that part of the code should expect some string to be sent to it, and she will know how to handle its storage.
As for calling the GoToMap method, you must configure the delegate for your MoreInfo class when you create it. Therefore, in your MoreInfo header, you will have, among other things,
@interface MoreInfo .... { id delegate; // everything else; } @property (nonatomic, assign) id delegate; // your methods and other properties; @end
Then, when you create it in your view controller, you will have
MoreInfo *moreInfoView = [[MoreInfo alloc] initWithNibName:@"MoreInfo" bundle:nil]; moreInfoView.title = view.annotation.title ; moreInfoView.delegate = self; // this assigns the current view controller as its delegate; //moreInfoView.getDirections = [NSURL URLWithString:[NSString stringWithFormat: @"http://maps.google.com/maps?q=%@@%1.6f,%1.6f&z=10", view.annotation.coordinate.latitude, view.annotation.coordinate.longitude]]; moreInfoView.getWebsite = view.annotation.website; [self.navigationController pushViewController:moreInfoView animated:YES];
Finally, when you want to call GoToWebsite from your MoreInfo, you can call
[self.delegate GoToWebsite]
This, of course, assumes that the method is in your first view controller (which I could swear it, but can't find it all of a sudden).
But basically how you do it