Reputation: 377
In my Tabbed Application, I added subview of type MapBox RMMapView to my main view.
My problem is the map center gets thrown off when I change orientation. The map view adjust to the orientation but the center of the map does not. Please provide suggestions to fix it? Thank you for your time.
** I tried both setAutoresizingMask but it has no effect.
[self.view setAutoresizingMask: (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[self.mapView setAutoresizingMask: (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
Upvotes: 0
Views: 254
Reputation: 377
I've been able to solve this by defining the view.frame for each orientation.
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
CGRect frame = CGRectMake(x, y, x, y);
_mapView.frame = frame;
_mapView.userTrackingMode = RMUserTrackingModeFollow;
} else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
CGRect frame = CGRectMake(x, y, x, y);
_mapView.frame = frame;
_mapView.userTrackingMode = RMUserTrackingModeFollow;
}
}
Upvotes: 0
Reputation: 5128
Not sure why this is the case, but I would recommend that you not add or manipulate subviews within the RMMapView
, but instead add one over top.
Upvotes: 1