I have a detail view that is pushed from a map. I am trying to get the title and subtitle from the annotation to show in the detail view. I can get the title to show in the Navigation bar, but I cannot get them to show up as UILabels. I have UILabels in my interface builder for the MapDetailInfo all connected to the “name” and “address”, but they will not fill when the view is pushed. Here is my code:
In My Map View Controller
- (void)mapView:(MKMapView *)mapView
annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control
{
MapDetailInfo *abc = [[MapDetailInfo alloc]init];
abc.title = view.annotation.title;
[self.navigationController pushViewController:abc animated:YES];
nameText.text = view.annotation.title;
addressText.text = view.annotation.subtitle;
}
In My Detail View Controller:
- (void)viewDidLoad
{
[super viewDidLoad];
BusinessListingsPart3ViewController *blv = [[BusinessListingsPart3ViewController alloc] init];
name.text = blv.nameText.text;
address.text = blv.addressText.text;
}
Any help would be much appreciated. Thanks!
Both
nameandaddressare not instantiated at this time. Their values will benil.Declare
nameTextandaddressTextas properties, set them in this method and then later update the labels in theviewDidLoadmethod.MapDetailInfo.h
MapDetailInfo.m
In the current method
mapView:annotationView:calloutAccessoryTapped:, replacewith
And in
MapDetailInfo‘sviewDidLoadmethod, add