我正在使用带有故事板的Google Maps iOS SDK开发iOS应用程序.在我的主视图控制器"viewDidLoad"中,我实现了一个GMSMapView并显示它
self.view = mapView_;
Run Code Online (Sandbox Code Playgroud)
一切都很好.现在我想在地图上添加一个UIView或UIButton,比如myLocation按钮样式.有什么解决方案可以添加它并通过故事板使用它吗?我已经通过代码在地图上叠加了对象,但我真的需要自动布局,所以通过Storyboard管理它会很好.谢谢.
我是iOS编程的新手,对COCOA Touch知之甚少.我试图在Google地图底部的屏幕上添加一个按钮,以便用户选择返回上一个屏幕.我只知道它UIButton是一个子类,UIView我们可以通过使按钮成为该类的子视图来使按钮出现在视图中.以前iOS默认使用谷歌地图MKMapView,我在互联网上看过书中的例子,显示应用程序的屏幕截图,其中按钮或文本框将出现在地图上.但现在只需拖动界面构建器中的按钮就无济于事了.

这是我的代码:
ViewController.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <GoogleMaps/GoogleMaps.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIButton *btn;
@end
Run Code Online (Sandbox Code Playgroud)
ViewController.m
#import "ViewController.h"
#import <MapKit/MapKit.h>
#import <GoogleMaps/GoogleMaps.h>
#import <CoreLocation/CoreLocation.h>
@interface ViewController ()
@end
@implementation ViewController
{
GMSMapView *mapView_;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} …Run Code Online (Sandbox Code Playgroud)