Search code examples
iosobjective-cuitabbarcontrollermkmapview

MKMapView not full screen with TabBar


I am making a simple app to display various things and on one of the tabs I like for it to display a map of your current location. It seems for some reason, even though in Xcode the controller is stretched towards the bottom, it looks like when run in the simulator, an area of unused space and I am unsure why.

I have the following code:

@interface MapViewController ()
@property (weak, nonatomic) IBOutlet MKMapView *map;
@end

@implementation MapViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
   _map.delegate = self;
   _map.showsUserLocation = YES;
}

-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
   _map.centerCoordinate = userLocation.location.coordinate; 
   MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 200, 200);
   [self.map setRegion:[self.map regionThatFits:region] animated:YES];
}

Xcode Map View Simulator View


Solution

  • You need to add the constraints.

    enter image description here