我通过Googla地图iOS开发工具包实现了GMSMapView
Google的示例代码建议在代码中或多或少地声明视图
- (void)loadView {
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = mapView_;
}它会自动工作,但是mapView恰好覆盖了我的navigationItem很明显,映射的维度位于initWithFram:CGRectZero,但只需将参数更改为自定义的CGRect
CGRect square = CGRectMake(100, 100, 100, 100);对我不起作用,还有其他建议吗?我只需要显示导航项目和选项卡栏之间的映射(但第二个不会被覆盖)

发布于 2013-06-28 18:26:13
问题是mapView_被设置为整个视图
self.view = mapView_;计算正确的维度并将其添加为子视图是解决该问题的正确方法
CGRect f = self.view.frame;
CGRect mapFrame = CGRectMake(f.origin.x, 44, f.size.width, f.size.height);
mapView_ = [GMSMapView mapWithFrame:mapFrame camera:camera];
[self.view addSubview:mapView_];发布于 2013-06-26 07:51:53
确保地图的视图控制器是UINavigationController导航堆栈的一部分。我可以毫不费力地将带有地图和列表选项卡的UITabBarController推送到嵌入在UINavigationController中的视图控制器上。这样,导航栏视图只属于UINavigationController,而地图控制器视图不应该覆盖它。
https://stackoverflow.com/questions/17308986
复制相似问题