iOS Objective-C谷歌地图仅在添加到子视图时在调试时显示

iOS Objective-C谷歌地图仅在添加到子视图时在调试时显示,ios,objective-c,iphone,Ios,Objective C,Iphone,我使用的是谷歌地图SDK,首先一切正常,但它显示为全屏。将地图添加到子视图后,地图将不再显示。我在iAction上添加了一个断点,并注意到在通过后: self.mapView1 = [GMSMapView mapWithFrame:_subview.bounds camera:camera]; 地图在子视图中显示得非常完美 这是我在IBAction中的代码: GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:33

我使用的是谷歌地图SDK,首先一切正常,但它显示为全屏。将地图添加到子视图后,地图将不再显示。我在iAction上添加了一个断点,并注意到在通过后:

self.mapView1 = [GMSMapView mapWithFrame:_subview.bounds camera:camera];
地图在子视图中显示得非常完美

这是我在IBAction中的代码:

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:33.67 longitude:35.55 zoom:12];

self.mapView1 = [GMSMapView mapWithFrame:_subview.bounds camera:camera];

self.mapView1.myLocationEnabled = YES;
[_mapView1 setMinZoom:12 maxZoom:20];
self.mapView1.mapType = kGMSTypeSatellite;
self.mapView1.settings.compassButton = YES;
_mapView1.delegate = self;
[_mapView1 animateToViewingAngle:45];

// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(33.67, 35.55);
marker.title = @"City";
marker.snippet = @"Country";
marker.map = _mapView1;
[_subview addSubview:_mapView1];


提前感谢。

由于我无法发表评论,我将用这种方式请您做一些事情:

1-向此行添加一个breankpoint并选中_subview.bounds值

self.mapView1=[GMSMapView mapWithFrame:_subview.bounds camera:camera]


2-在模拟器中运行时,单击“调试>视图调试>捕获视图层次结构”,找到AVPlayer,检查右面板上的属性。

在创建GMSMapView时检查_subview.bounds


根据完成时间的不同,可能没有设置,您可能会得到一个CGRectZero帧。

试试这个,它对我有用

GMSMapView *customView = [[GMSMapView alloc] initWithFrame:CGRectMake(100, 300, 100, 100)];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:33.67 longitude:35.55 zoom:12];

customView = [GMSMapView mapWithFrame:customView.bounds camera:camera];

customView.myLocationEnabled = YES;
[customView setMinZoom:12 maxZoom:20];
customView.mapType = kGMSTypeSatellite;
customView.delegate = self;
[customView animateToViewingAngle:45];

// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(33.67, 35.55);
marker.title = @"City";
marker.snippet = @"Country";
marker.map = customView;
[self.view addSubview:customView];


同时检查您的_子视图是否隐藏。

请添加一些屏幕截图以了解您想要做什么?@SiddheshMhatre屏幕截图通过在iAction代码中将self.mapView1替换为_子视图来添加内容。替换@siddheshmhatredd后的相同结果您将GMSMapView添加为_子视图的类?我应该首先在何处和何时创建它?请尝试viewDidLayoutSubviews.same没有任何更改:(在self.mapView1=[GMSMapView mapWithFrame:_subview.bounds camera:camera]上放置断点;并检查边界。是的,我正在尝试。谢谢你第一个操作非常成功。
GMSMapView *customView = [[GMSMapView alloc] initWithFrame:CGRectMake(100, 300, 100, 100)];

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:33.67 longitude:35.55 zoom:12];
_mapView = [GMSMapView mapWithFrame:customView.bounds camera:camera];

_mapView.myLocationEnabled = YES;
[_mapView setMinZoom:12 maxZoom:20];
_mapView.mapType = kGMSTypeSatellite;
_mapView.settings.compassButton = YES;
_mapView.delegate = self;
[_mapView animateToViewingAngle:45];

// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(33.67, 35.55);
marker.title = @"City";
marker.snippet = @"Country";
marker.map = _mapView;
[customView addSubview:_mapView];
[self.view addSubview:customView];