Google Maps iOS SDK - 在GMSMapView上添加UIView / UIButton [英] Google Maps iOS SDK - Add UIView/UIButton over a GMSMapView

查看:116
本文介绍了Google Maps iOS SDK - 在GMSMapView上添加UIView / UIButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有故事板的Google Maps iOS SDK开发iOS应用。
在我的主视图控制器viewDidLoad中,我实现了一个GMSMapView,并按

  self.view =显示它mapView_; 

一切顺利。现在我想在地图上添加一个UIView或UIButton,比如myLocation按钮样式。有什么解决方案可以添加它并通过故事板使用它吗?我已经通过代码在地图上叠加了对象,但我真的需要自动布局,所以通过Storyboard管理它会很好。
谢谢。

解决方案

试试这个
(确保将mapView框架设置为不同于CGRectZero(仅适用于self.view = mapView)):

  mapView = [GMSMapView mapWithFrame:self.view.bounds camera :相机]; 
[self.view insertSubview:mapView atIndex:0];

正如Saxon所说,在索引0处插入视图会将其余的对象设置在前面。 / p>

I'm developing an iOS app with Google Maps iOS SDK with storyboard. On my main view controller in "viewDidLoad" I have implemented a GMSMapView and shows it by

self.view = mapView_;

and everything goes fine. Now I want to add a UIView or UIButton over the map, like myLocation button style. There is any solution to add it and use it via storyboard? I've overlayed objects on the map by code but i really need autolayout so manage it via Storyboard would be nice. Thanks.

解决方案

Try this (making sure you set the mapView frame to a value different than CGRectZero (which works for self.view=mapView only)):

mapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
[self.view insertSubview:mapView atIndex:0];

As Saxon said, inserting the view at index 0 will set the rest of the objects in front.

这篇关于Google Maps iOS SDK - 在GMSMapView上添加UIView / UIButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆