Search code examples
iosobjective-cios7mkmapviewstatusbar

Adding MKMapView Causes Status Bar Issue in iOS 7


I'm solving the status bar issue in iOS 7 using

if(st.version == 7)
{
    CGRect screen = [[UIScreen mainScreen] bounds];
    CGRect frame = self.navigationController.view.frame;
    frame.origin.y = 20;
    frame.size.height = screen.size.height - 20;
    self.navigationController.view.frame = frame;
}

Since I'm using navigation controller and pushing from one to another using [self.navigationController pushViewController:newone animated:YES];. It works fine in all view controllers. But, if the viewcontroller has mkmapview in xib, status bar issue of ios 7 occurs.

If I delete the mapview form xib and push to that view controller means, it will be like,

enter image description here

If I add the mapview even by code below,

mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 100, 320, 100)];
[self.view addSubview:self.mapView];

It looks like,

enter image description here

How to solve this?


Solution

  • If you add mapView in viewWillAppear replace it in viewDidAppear.
    Maybe you have this issue because you're doing manipulations with view's frames before your view is completely set up