I am developing an iPhone application for a university project and I’m new to iPhone development. I have looked through Apple’s MapCallouts code but it doesn’t seem feasible to implement it.
So far my code displays a map, drops annotations, displays the title and it displays the right call out button. But this is where I encounter problems.
When I press on the callout button, it displays a blank view controller but it should display a different image for every callout that’s tapped and this isn’t happening so far.
I have added my code below:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control
{
//NSUInteger tag = ((UIButton *)control).tag;
if (self.detailController==nil)
{
DetailViewController* detailViewController = [[DetailViewController alloc] init];
[self.navigationController pushViewController:detailViewController animated:YES];
}
// self.detailController.tag =1; //to identify image required
// self.detailController.tag = tag;
[self.navigationController pushViewController:detailController animated:YES];
}
If you are using storyboard, then you should already have a view controller. I’m assuming your code is in the class that your view controller is an instance of.
The easiest (least coding required) way to present an image is to:
You can do this for each image you want, but it is messy. Consider also subclassing the image controller and programmatically defining the image you want to show up. You may need to do this anyway if you want to dismiss the image with the dismiss modal view controller method. The alternative would be adding another segue that points backward.