I am trying to put a google maps view into a UIView
in my app. The UIView
was created inside a UIViewController
in the stroryboard and I added I few auto layout constraints.
I am able to load the map inside the UIView
based in the answer of this post:
How to put Google Map in a custom UIView
However, when I load the view in (void)viewDidLoad
method, it seems to completely ignore the constraints and maps get out the screen in some iPhones sizes (I could check this using Debug View Hierarchy). If I do not load the (void)viewDidLoad
but instead, do this when the user press a button (ig.: IBAction), everything works perfectly.
I'm using exactly the same code in both situation. I've no ideia why the behaviour is different. Any help?
The code that I am using to load the maps into UIView
:
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:latitude
longitude:longitude zoom:13];
mapView_ = [GMSMapView mapWithFrame:_mapsView.bounds camera:camera];
mapView_.settings.compassButton = YES;
mapView_.settings.myLocationButton = YES;
[self.mapsView addSubview:mapView_];