Google maps sdk - 地图覆盖了我故事板中的所有内容
Google maps sdk - Map overlays evrything in my storyboard
所以我正在使用 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;
}
还是谢谢你
日本
当您执行 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
所以我正在使用 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;
}
还是谢谢你 日本
当您执行 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