- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
self.mapView.frame = self.view.bounds;
self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
CLLocationCoordinate2D startCoord = CLLocationCoordinate2DMake(36.7472, -95.9594);
MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:MKCoordinateRegionMakeWithDistance(startCoord, 10000*1609.344, 10000*1609.344)];
[self.mapView setRegion:adjustedRegion animated:YES];
}
That's the code I have right now. When I change the orientation of my iPad from landscape to portrait, the map view's size doesn't change. I would like it to fill the entire view. I have tried searching google and stackoverflow for a solution, but I haven't had any luck.
Any help would be immensely appreciated.
-(void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
self.mapView.frame = self.view.bounds;
}
This will ensure that the map frame will adjust to the view bounds whenever the view controller layout is triggered (like, on autorotation).
You can actually take the set frame line out of viewWillAppear, since viewWillLayoutSubviews runs at initial setup time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With