【问题标题】:Google maps sdk - Map overlays evrything in my storyboardGoogle maps sdk - 地图覆盖了我故事板中的所有内容
【发布时间】:2015-04-07 09:19:48
【问题描述】:

所以我正在使用 xcode 6.2,我开始制作应用程序。 但我有一个问题:每当我在我的故事板中拖动一些东西,比如导航栏,地图就会覆盖它,它根本不会出现,请帮忙。 这是我的代码

#import "ViewController.h"

@interface ViewController () {
    GMSMapView *mapView;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:43.642510 longitude:-79.387038 zoom:12 bearing:0 viewingAngle:0];
    mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
    mapView.myLocationEnabled = YES;
    self.view = mapView;


    GMSMarker *marker = [[GMSMarker alloc] init];
    marker.position = CLLocationCoordinate2DMake(43.642510, -79.387038);
    marker.title = @"CN-Tower";
    marker.snippet = @"A beautifull tower";
    marker.map = mapView;
    marker.opacity = 0.7;
}

无论如何,谢谢, JP

【问题讨论】:

    标签: xcode google-maps-sdk-ios


    【解决方案1】:

    当您执行self.view = mapView 时,您将视图控制器的根视图设置为地图 - 因此地图将覆盖所有内容,替换您在情节提要中设计的任何内容。

    您需要做的是将地图添加为根视图的子视图,例如以下几种方法:

    Using the Google Maps SDK in views other than the main view

    Google Maps iOS SDK - Add UIView/UIButton over a GMSMapView

    Google Maps iOS SDK and storyboards

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多