在uiview中显示谷歌地图

时间:2014-12-23 14:17:06

标签: ios objective-c google-maps

我创建了UIView的子类并将其粘贴到MyViewController中。在MyViewController中,我正在尝试插入Google,但它不会影响(只是一个白色屏幕)。但是,如果我尝试将代码插入到相似之处,那么一切正常。

// this code work good 
UIAlertView *helloWorldAlert = [[UIAlertView alloc]
                                    initWithTitle:@"My First App" message:@"Hello, World!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

    // Display the Hello World Message
    [helloWorldAlert show];

我需要做什么才能反映出UIView Google地图的子类?

// this is my code and this is not work


GMSMapView *mapView_;
[GMSServices provideAPIKey:@"#######"];



GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                        longitude:151.20
                                                             zoom:1];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
mapView_.settings.compassButton = YES;
mapView_.settings.myLocationButton = YES;

1 个答案:

答案 0 :(得分:0)

您可以通过编程方式将mapView_添加为UIView的子视图。

您可以参考其他问题中发布的my answer

mapView.frame = CGRectMake(YOUR_MAP_X, YOUR_MAP_Y, YOUR_MAP_WIDTH, YOUR_MAP_HEIGHT);
[self.view addSubview:mapView_];