iPhone: Use a view as a transparent overlay with closing button
- by axooh
I've got a map with three bar buttons for different markers to show up in the map. If I click on a bar button, the specific markers are shown in the map, which already works great.
Now I would like to show a transparent overlay (popup window) with the description of the markers after I clicked on a bar button with a button to close the overlay again and show the markers (which are set in the background).
The function of the bar button:
- (IBAction)routeTwo:(id)sender
{
// The code for the overlay
// ...
// remove any annotations that exist
[map removeAnnotations:map.annotations];
// Add any annotations which belongs to route 2
[map addAnnotation:[self.mapAnnotations objectAtIndex:2]];
[map addAnnotation:[self.mapAnnotations objectAtIndex:3]];
[map addAnnotation:[self.mapAnnotations objectAtIndex:4]];
[map addAnnotation:[self.mapAnnotations objectAtIndex:5]];
}
I tried the following possibilities:
1. Using a modal view controller
RouteDescriptionViewController *routeDescriptionView = [[RouteDescriptionViewController alloc] init];
[self presentModalViewController:routeDescriptionView animated:YES];
[routeDescriptionView release];
Works great, but the problem is: The map view in the background is not visible anymore (configuring alpha values of the modal view doesn't change anything).
2. Add RouteDescriptionView as a subview
RouteDescriptionViewController *routeDescriptionView = [[RouteDescriptionViewController alloc] init];
[self.view addSubview:routeDescriptionView.view];
[routeDescriptionView release];
Works great as well, but the problem here is: I can't configure a close button on the subview to close/remove the subview (RouteDescriptionView).
3. Using UIAlertView
Would work as expected, but the UIAlert is not really customizable and therefore not suitable for my needs.
Any ideas how to achieve this?