Reputation: 6614
I have a mapView in a view in a nib file with the delegate set to file's owner and the outlet is set to IBOutlet MKMapView* mapView;
the problem I'm having is that the map is above all other objects. If I add a UIView you don't see it because it is beneath the map.
any idea why this might happen? I haven't had this problem before
thanks.
Upvotes: 1
Views: 777
Reputation: 171
The easiest way is to change the "Z" order in interface builder. Select the view or other UI element and then look under the Editor menu for Arrange. There you will find
Send to front
Send to back
Send forward
Send backward
Upvotes: 1
Reputation: 2527
The answer is quite simple, you need to add the object you created as a subview to your MapView.
For example, here is how you would add an UILabel to the MapView. Just do this in init
- (void)viewDidLoad
{
[super viewDidLoad];
// Create the label
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 320)];
label.backgroundColor = [UIColor whiteColor];
label.text = @"I'm on top of the Map!";
// Add the label to the mapView
[self.mapView addSubview:label];
// Release the label if you are not using ARC
[label release];
}
Edit: Keep in mind this concept applies to other objects such as a UISegmentedControl.
Upvotes: 3
Reputation: 6166
Why would you want to add a label or any control over mkmapview , you can instead use its delegate to add an overlay or annotation. Also if your problem is that mapview is coming all over the screen then set its frame.
If any other case , please explain your problem more clearly.
According to our discussion you can use the function:-
[self.view bringSubViewToFront:yourView];
Upvotes: 3